texts:
I want to make my biped robot keep walking, but it only move for twice, this biped robot project is important for my Capstone project. The code below is the code that I used

#include <Servo.h>

int HipR_Pin = 9;
int HipL_Pin = 10;

int KneeR_Pin = 5;
int KneeL_Pin = 6;

int AnkleR_Pin = 3;
int AnkleL_Pin = 11;

Servo HipR;
Servo HipL;

Servo KneeR;
Servo KneeL;

Servo AnkleR;
Servo AnkleL;

void setup() {
  HipR.attach(HipR_Pin);
  HipL.attach(HipL_Pin);
  KneeR.attach(KneeR_Pin);
  KneeL.attach(KneeL_Pin);
  AnkleR.attach(KneeR_Pin);
  AnkleL.attach(KneeL_Pin);
}

void loop() {

  for (int i=0; i < 7; i++)
  {
    RightStep1;
    LeftStep1;
    RightStep2;
    LeftStep2;
    RightStep3;
    LeftStep3;
    RightStep4;
    LeftStep4;
  }
  ;
}

void RightStep1()
{
  HipR.write(80);
  HipL.write(80);
  KneeR.write(100);
  KneeL.write(100);
  AnkleR.write(20);
  AnkleL.write(20);

}

void LeftStep1()
{
  HipR.write(90);
  HipL.write(90);
  KneeR.write(70);
  KneeL.write(70);
  AnkleR.write(20);
  AnkleL.write(20);

}

void RightStep2()
{
  HipR.write(70);
  HipL.write(70);
  KneeR.write(80);
  KneeL.write(80);
  AnkleR.write(10);
  AnkleL.write(10);

}

void LeftStep2()
{
  HipR.write(60);
  HipL.write(60);
  KneeR.write(90);
  KneeL.write(90);
  AnkleR.write(20);
  AnkleL.write(20);

}
void RightStep3()
{
  HipR.write(40);
  HipL.write(40);
  KneeR.write(60);
  KneeL.write(60);
  AnkleR.write(10);
  AnkleL.write(10);

}

void LeftStep3()
{
  HipR.write(50);
  HipL.write(50);
  KneeR.write(70);
  KneeL.write(70);
  AnkleR.write(20);
  AnkleL.write(20);

}
void RightStep4()
{
  HipR.write(60);
  HipL.write(60);
  KneeR.write(60);
  KneeL.write(60);
  AnkleR.write(10);
  AnkleL.write(10);

}

void LeftStep4()
{
  HipR.write(70);
  HipL.write(70);
  KneeR.write(50);
  KneeL.write(50);
  AnkleR.write(20);
  AnkleL.write(20);

}


texts: How do I start a task and have it run for a set amount of time?

texts: I have a project where I need to turn a 24V solenoid on for a set amount of time, then have it turn off. I am rather new to Arduino and not certain how to do this or really where to start. Ideally the time would be displayed on a LCD screen as well but this is purely aesthetic. Any advice, help, examples ect would be appreciated. Thanks!


texts: What is causing this warning in Arduino IDE?

texts:
I'm using DS3231 module with rinkydink library and it is working just fine, however every time i want to compile the code Arduino IDE shows this warning:

  C:\Program Files (x86)\Arduino\libraries\DS3231\DS3231.cpp:291:106:
  warning: ISO C++ forbids converting a string constant to 'char*'
  [-Wwrite-strings]

What is this warning and how to solve it?


texts: MAX485 communication between multiple Arduinos

texts:
I purchased multiple Arduino Mini Pros and MAX485 TTL boards and now I'm trying to make them communicate together, but the problem is that I need that everyone can send and receive when needed.

I mean, normally, the "Master" request something and then the right "Client" responds. But in my application everyone's master and everyone can send at anytime to anyone. Is there a library, that synchronizes the Read/Write between those Arduinos, so that when one is sending (at anytime) that the other ones won't send, until the transmission of the Arduino who's sending is over?

If there's no library, could I attach one more pin between all Arduinos that act like a PTT switch? When one want to send, it pulls the pin X high and if some other Arduino want to send, it checks for that high pin: If it's high, it will wait. Could that work too? Or maybe this isn't reliable?

Any suggestion or help are highly appreciated.


texts: digitalwrite with function parameter as parameter

texts:
Firstly, excuse my poor English, this is not my native langage.
I'm trying to use an Arduino Uno to drive an 8 relay board from an MQTT Subscription. I ask for help because i'm some kind of beginner in arduino, i'm just a Linux addict.
The idea is to get a payload from PubSubclient and use it to manage relays.
For example, the payload '71' ask the relay 7 to turn on and '42' make the relay 4 to turn off.
All works fine until I wanted to write a function with two parameters : 'relay_number' and 'Action'
All parameters are received but the relay never goes up or down.
My code :
void callback(char* topic, byte* payload, unsigned int length) {

  Relay_Nb = (char)payload[0];
  Action = char(payload[1]);

  Serial.println(Relay_Nb);
  Serial.println(Action);

  RelayControl(Relay_Nb, Action);
}

void RelayControl(char Relay_Nb, char Action) {
  Serial.println(Relay_Nb);   // for debugging purpose
  Serial.println(Action);

  if ( Action == '0') {
    Serial.print("Bringing down Relay ");
    Serial.println(Relay_Nb);
    digitalWrite(Relay_Nb, LOW);
  } else if (Action == '1') {
    Serial.print("Bringing up Relay ");
    Serial.println(Relay_Nb);
    digitalWrite(Relay_Nb, HIGH);
  } else if (Action == '2') {
    // Relay temporisé (ouverture portail par ex)
    Serial.println("Bringing up, and down Relay ");
    digitalWrite(Relay_Nb, HIGH);
    delay(750);
    digitalWrite(Relay_Nb, LOW);
  }
}

I'm sure an old maker have the solution i'm searching for hours now.
Please help and don't hesitate to show me others ways.
Thanks.


texts: How do I get the size of my program at runtime?

texts:
(This question is specific for the Arduino Due, but maybe there's a general answer to the question)
I'm using DueFlashStorage to store application data in the flash memory of my Arduino Due. That works quite nicely. The Due has two flash blocks with 256k each. By default, the library writes data to the second flash block. The first flash block is used for the program. My program currently uses around 160k of flash (as the compiler tells me). That leaves about 96k of flash unused, which I could really use to store more application data. I managed to adjust DueFlashStorage to allow writing to the full memory range, but how do I detect where it is safe to write to? (Obviously, I must not overwrite any part of the program)
I have tried something like:
  // this returns the logical address of the first byte in flash (0x80000)
  byte* startAddr = dueFlashStorage.readAddress(0);
  Serial.println((unsigned int)startAddr, HEX);
  int bytes = 0;
  while (bytes < 512 * 1024) // That's the size of the flash
  {
    int* data = (int*)(startAddr + bytes);
    if (*data == 0xFFFFFFFF) // empty flash is initialized with FF's
     {
       Serial.print("Free block at 0x");
       Serial.println((unsigned int)data, HEX);
     }
     else
     {
       Serial.print("Used block at 0x");
       Serial.println((unsigned int)data, HEX);
     }
    bytes+=512;
  }

This seems to work, as the first block detected as "free" is just above the size of the program. However, this approach has some major drawbacks:

It's slow. Running over the whole address space to find the end of the program uses time (and maybe I shouldn't just test the first word of each block)
It's not reproducible. After I have written data to the detected first free block, it's no longer free, so I need another approach (like some magic number) to detect the first data block after the CPU is reset.

Is there a better way for this (like, in the ideal world, a constant I could use)? I don't want to hardcode the data start, because as the program grows (and it's still in development) I would forget to adjust that constant and booooommmm....


texts:
I need to power my arduino and 2 DC motors requiring 6V each, I want to power the DC motors with a 6V battery through the vM pin on an h-bridge and use a 9V battery to power the Arduino itself.

On my breadboard I have a dedicated power line and ground line on each side, is it okay to share the ground between both batteries and consequently share grounds for any servo motors or sensors i connect?


texts:
I am trying to control this OWI Robotic Arm using the Arduino's digital outputs (I am using pins 12 & 13).

If I wire up the wires to ground and 5V it goes one way, if I switch the wires, it goes the other way. However when I have the pins wired up to the digital pins, it does not work, but the on-board LED does blink.

The code:

int a = 12;
int b = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  //up
  digitalWrite(a, LOW);
  digitalWrite(b, HIGH);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  //down
  digitalWrite(b, LOW);
  digitalWrite(a, HIGH);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
}


texts: Serial port field greyed out with error on launch (Ubuntu 14,04)

texts:
I know this has been asked several times already, but I've nevered seen it asked with an error included on launch.

Here is the message that comes up in the terminal when I launch arduino (with root privileges if thats relevant):

(java:9042): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

When I try to compile the code, it gives me the standard, "COM1 NOT FOUND" and a bunch of other errors. I can post the entire error message here.

Any suggestions?


texts: I²C with ATTiny85 at 8MHz using TinyWireM library

texts:
Hello fellow Arduino enthusiasts, I am trying to make the ATTiny85 talk I²C with a MMA7660 breakout board I have (it's an accelerometer, this is a follow up question to my previous one).

I would state in advance that the I²C chip works perfectly with Arduino Nano, that I am using the Arduino IDE v1.5.6-r2, using the arduino-tiny core (from here) and that until now I had no special issues working at 8MHz.

The official documentation for the TinyWireM library (at the Arduino playground website) states that:

  By default the I2C master library (TinyWireM) is set to run at 1MHz.
  To run at 8MHz, #defines in USI_TWI_Master.h / .cpp must be changed.

I have made the following changes in USI_TWI_Master.cpp:

#define F_CPU 8000000UL // was 1000000UL

I have made the following changes in USI_TWI_Master.h:

#define SYS_CLK   8000.0 // was 1000.0
#define T2_TWI    1.3 // was 5
#define T4_TWI    0.6 // was 4

My guess is that the T2_TWI & the T4_TWI values are wrong. I also tried T2_TWI 40 and T4_TWI 32 (as stated here), and T2_TWI 2 & T4_TWI 1 (as stated here) but no luck. I also tried some other values in between that I thought might make sense but it won't work.

The code I am running is the I²C scanner from here (which as I mentioned works perfectly with the Nano and finds the device), the blow is a modified version for interfacing the TinyWireM library instead of the Wire library:

#include <TinyWireM.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(-1,4);

void setup()
{
  TinyWireM.begin();
  mySerial.begin(9600);
  mySerial.println("\nI2C Scanner");
}

void loop()
{
  byte error, address;
  int nDevices;
  mySerial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    TinyWireM.beginTransmission(address);
    error = TinyWireM.endTransmission();

    if (error == 0)
    {
      mySerial.print("I2C device found at address 0x");
      if (address<16)
        mySerial.print("0");
      mySerial.print(address,HEX);
      mySerial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      mySerial.print("Unknow error at address 0x");
      if (address<16)
        mySerial.print("0");
      mySerial.println(address,HEX);
    }
  }
  if (nDevices == 0)
    mySerial.println("No I2C devices found\n");
  else
    mySerial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

As a side note I would say that my logic analyzer was broken recently and I'm sure it would have helped here... Also I am aware of the sound-card hack to be used as logic analyzer, but would prefer to avoid adding more error-prone variables to the system, if possible, for now.

Here is a picture of probing with Saleae logic analyzer of the two channels. The result of the code above is "No I2C devices found":

(Full size picture)

Would appreciate the insights of anyone with experience using ATTiny85 at 8Mhz with I²C successfully.


texts: Remove unwanted characters from char type

texts:
I'm working on an ESP8266 module that needs to fetch date data from worldtimeapi, everything works fine but the problem is How do I strip of the time field off the datetime JSON response without loop.
Note: Arduino JSON library was used in deserializing the response data and it seems the library only supports char data type.
void loop ()
{
  // Initialize the request object
  HTTPClient request;

// Make a http request
  request.begin(dateTime);
  delay(2000);

  // Check the request status code.
int  responseCode = request.GET(); //Get the api host response code.
  Serial.print("Response code is: ");
  Serial.println(responseCode);
  if (responseCode == 200); // If the server returned OK
  {
      String responseData = request.getString();
      Serial.println("Response from the server is:");
      Serial.println(responseData);
        // Deserialize the JSON response data
       StaticJsonDocument<715> result; // Declare data storage to stack

      //Check for error during data deserialization
      DeserializationError error = deserializeJson(result, responseData);

      if (error)
      {
        Serial.print(F("Response deserialization failed with reason: "));
        Serial.println(error.f_str());
        return;
      }

      else
      {
        char abbreviation = result["abbreviation"];  // Returns the current time zone abbreviation
        char timezone = result["timezone"]; // Returns the current time zone
        char datetime = result["datetime"]; // "2021-03-12T17:04:0
        char date = datetime.remove(9,22); // This line throws error : request for member 'remove' in 'datetime', which is of non-class type 'char'

        Serial.print("Current time is ");
        Serial.print(datetime);
        Serial.print(" ");
        Serial.print(abbreviation);
        Serial.print(" ");
        Serial.println(timezone);
        delay(2000);
      }

  }

}


texts: Cannot upload to otherwise working bootloaded ATmega328P via RS232: "programmer is not responding"

texts:
I have an ATmega328P on a breadboard with the following circuitry around it:

The ISP is a Tiny AVR Programmer. The RS232 to USB converter is this thing.
Following is the test program I use:

void setup() {
    Serial.begin(28800);
    DDRC  = 0b00000001;
    PORTC = 0b00000000;
}

void loop() {
    PORTC = 0b00000001;
    delay(300);
    PORTC = 0b00000000;
    delay(300);

    int Data;
    char Text[2] = {0};
    while (true)
    {
        Data = Serial.read();
        if (Data == -1) break;
        Text[0] = 0xFF - Data;
        Serial.write(Text);
    }
}

Almost everything is working fine:

I can upload the program via ISP by holding the shift-key while pressing the upload-button in Arduino IDE.
The LED on Pin 23 (PC0) blinks.
When I press the reset button the LED stops blinking and when I release the button it starts blinking again, so resetting the chip works.
When I open a serial monitor (at 28800 baud and not the one integrated in Arduino IDE) I can send 00, 01, 02, 03, ... and I receive FF, FE, FD, FC, ... back, so the serial communication works.
I can burn the bootloader from Arduino IDE. Every time I reset the chip the LED on pin 19 blinks three times in rapid succession and then stays off.

But I can't upload the program through the serial connection once the bootloader is burned.
Arduino IDE shows the following output:

C:\Portable Program Files\arduino-1.8.5\hardware\tools\avr/bin/avrdude -CC:\Portable Program Files\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM6 -b115200 -D -Uflash:w:C:\Users\Niko\AppData\Local\Temp\arduino_build_706815/BlinkTest.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Portable Program Files\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xe0

(And of course the 9 other attempts follow.)
I am not sure what to do here. Maybe the baudrate is incorrect? The Arduino website says that Arduino bootloaders use 19200 baud. But executing the same command in a console but changing the -b115200 to -b19200 yields the same result. I also tried 9600.
I make sure to to reset the chip before trying to upload, though I can't really say whether I get the timing right.

Something I noticed is that The Arduino website says that "Burning the bootloader may take 15 seconds or more", but burning the bootloader takes less than a second for me. Seems unusually fast but I can't see any errors in the output.

I also find it very weird that the command executed when trying to upload via serial connection contains -carduino, which would imply that it's trying to use a programmer to upload the program. The bootloader should make that unnecessary.

Any ideas?


texts: Burning Arduino Leonardo Bootloader to ATmega32U4 with 8MHz internal clock

texts:
Burning question:

So, I'm trying to burn the Arduino Leo bootloader onto a ATmega32U4 that's on 3.3V and the internal 8MHz clock.  Do I have to modify and rebuild the bootloader to set the fuses correctly, and can this be done with AVR Studio?

All of the references on doing this are dated.  The folder structure for the Arduino IDE has changed. I've done it in the past with 5V 16MHz 32U4s using an Arduino as ISP, but never with the AVRISP mkII on the Arduino IDE.

On the good side, I do have it up and running with Atmel Studio.

Thanks!


texts: Programming many Arduinos simultaneously with a wireless broadcast

texts:
I will have many microcontroller-based devices which will be independent from each other, but all will run the same program.

I would like to upload a program to all of them at the same time with a wireless broadcast. Ideally the user would plug in a USB controller to his computer, and upload a program from the Arduino environment as if s/he were programming a single device.

To get a better idea of what I'm talking about, please take a look at this video. This was achieved with Atmel microcontrollers but a custom-made, non-Arduino bootloader.

From a Google search for "Arduino infrared programming" this interesting project came up. The main drawback is that the reset button still has to be pressed manually. Ideally I would like the devices to be in a low-power state by default, and wake up to receive a program when they sense a signal from the controller. Still, this may be a good starting point for me.

I just wanted to get some perspectives from people who are familiar with Arduinos as to whether they think this is feasible before I jump in.


texts: Use Arduino Yun Shield as ISP for bootloaded ATMega328-PU

texts:
My question is how do I replace the Aarduino Uuno board in this circuit:

...With an Arduino Yun shield? I can setup the hardware - ICSP configuration is easy enough - but how do I go about using the IDE to do this? Cheers


texts: How can I change the speed of a stepper motor?

texts:
I am new to Arduino and am trying to implement different rotational speeds for a stepper motor. I am using a Nema 17 bipolar stepper motor, a Big Easy Driver, and an Arduino Uno.

I've been trying to modify a tutorial code such that it will run at variable speeds:

//Declare pin functions on Arduino
#define stp 2
#define dir 3
#define MS1 4
#define MS2 5
#define MS3 6
#define EN  7

//Declare variables for functions
char user_input;
int x;
int y;
int state;

#include <AccelStepper.h>
#include <Stepper.h>
Stepper stepper1 (1,stp,dir);

void setup() {

  pinMode(stp, OUTPUT);
  pinMode(dir, OUTPUT);
  pinMode(MS1, OUTPUT);
  pinMode(MS2, OUTPUT);
  pinMode(MS3, OUTPUT);
  pinMode(EN, OUTPUT);
  resetBEDPins(); //Set step, direction, microstep and enable pins to default states
  Serial.begin(9600); //Open Serial connection for debugging
  stepper1.setSpeed(1);
  Serial.println("Begin motor control");
  Serial.println();
  //Print function list for user selection
  Serial.println("Enter number for control option:");
  Serial.println("1. Turn at default microstep mode.");
  Serial.println("2. Reverse direction at default microstep mode.");
  Serial.println();

}

//Main loop
void loop() {
  while(Serial.available()){
      user_input = Serial.read(); //Read user input and trigger appropriate
function
      digitalWrite(EN, LOW); //Pull enable pin low to set FETs active and allow motor control
      if (user_input =='1')
      {
         StepForwardDefault();
      }
      else if(user_input =='2')
      {
        ReverseStepDefault();
      }
      else
      {
        Serial.println("Invalid option entered.");
      }
      resetBEDPins();
  }
}

//Reset Big Easy Driver pins to default states
void resetBEDPins()
{
  digitalWrite(stp, LOW);
  digitalWrite(dir, LOW);
  digitalWrite(MS1, LOW);
  digitalWrite(MS2, LOW);
  digitalWrite(MS3, LOW);
  digitalWrite(EN, HIGH);
}

//Default microstep mode function
void StepForwardDefault()
{
  Serial.println("Moving forward at default step mode.");
  digitalWrite(dir, LOW); //Pull direction pin low to move "forward"
  for(x= 1; x<4000; x++)  //Loop the forward stepping enough times for motion to be visible
  {
    digitalWrite(stp,HIGH); //Trigger one step forward
    delay(1);
    digitalWrite(stp,LOW); //Pull step pin low so it can be triggered again
    delay(1);
  }
  Serial.println("Enter new option");
  Serial.println();
}

//Reverse default microstep mode function
void ReverseStepDefault()
{
  Serial.println("Moving in reverse at default step mode.");
  digitalWrite(dir, HIGH); //Pull direction pin high to move in "reverse"
  for(x= 1; x<4000; x++)  //Loop the stepping enough times for motion to be visible
  {
    digitalWrite(stp,HIGH); //Trigger one step
    delay(1);
    digitalWrite(stp,LOW); //Pull step pin low so it can be triggered again
    delay(1);
  }
  Serial.println("Enter new option");
  Serial.println();
}

Adjusting the potentiometer on the Big Easy Driver will either stop the motor turning completely or run at a constant speed regardless of further adjustment.

Do you have any suggestions for debugging my code, or are there other functions I should be using in addition to/instead of those I have?


texts: How can I handle micros() double rollover?

texts:
I know that I can handle a single rollover with subtraction:

if (micros() - lastTime > period) {
  lastTime = micros();
  ...
}

But how it can be handled if this is not true or it is not checked for more than 70 minutes (without using uint64_t)?


texts:
I am powering a UNO through the 5V pin. I am using a tftlcd shield (2.8" mcufriend.com) on it.

To be able to use the shield with I2C I had to snip the RST leg from the shield. That was done because the shield used A4 which was required for I2C.
 When I power the UNO through the USB port the program starts correctly and a bitmap is loaded onto the screen. When I power up from the 5V pin or the power adapter, the screen remains white. I have to manually press the reset button on the UNO and then the program loads the bitmap.

The ladyAda examples had this to say;

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

Does that mean I should solder the lcd RST pin to the RESET on the UNO? (if so I am not sure how I can do that without taking the lcd shield to pieces).


texts: Is it possible to run two small motors off an Arduino and have the motors move separately based on a random number generator?

texts:
I am a 2nd year design engineering student working on a design project where we are tasked with automating the movement of a rainfall simulator. One of our design ideas consists of two small motors running perpendicular to each other with the movements based on a random number generator. I was told that this would be fairly easy if we used a Siemens Program Logic Controller, but we have a very limited budget so I thought I would check out other options.

I am not familiar with the Arduino or much of anything to do with programming so I thought it would be beneficial to ask for advice from some people who know what they are doing. I attached an initial sketch of the idea and a picture of the rainfall simulator to hopefully clarify what I am hoping to accomplish. The most the device can move from its rested state is only 0.5".

Is this a path worth working towards? Or is this not the proper choice of equipment?

Any advice would be greatly appreciated!

Thanks,

Nick


texts:
After trying to upgrade firmware of ESP8266, it failed. I am not finding any response from it. It's just blinking a red LED.

What will I do now?

I had tried to upgrade the firmwire in different ways...but couldn't.The result is that i am not finding any wifi signal response in the network connection ...What's now?


texts: Question regarding powering Arduino through the USB Port

texts: If powering the Arduino (Mega) through the USB port, is a voltage of 5.19VDC acceptable?


texts:
I was recently experimenting with 20x4 lcd display with my Arduino Mega board. The connections which I followed are shown in the picture attached. I am very much sure about the connections and code written in the Arduino IDE. Everything is compiled and uploaded properly on my board. However the problem I found is the 20x4 lcd display only shows two alternate block lines and nothing else! To resolve this I tried following things:

I made sure multiple times the hard wire connections between Arduino and display and found all are as per requirement.
I made sure the proper coding with initialization.
I tried changing the value of 10KOhm pot in order to control the contrast setting of lcd.
I made sure about connecting the R/W pin of lcd to ground.
I tried replacing the lcd display with another same unit.

With above troubleshooting the problem still persists. Can anybody will suggest what could be the issue?

Suggestions are highly appreciated!
Thanks and regards,
VK


texts: Convert string plus hexadecimals to array of hex:

texts:
I have a string which I send to the arduino using serial monitor. Something like that:

my specific string 0x0F 0x2C 0x98 0xBC

How can I parse this string in the arduino to get an array of hex values:

0x0F 0x2C 0x98 0xBD

? There are two prerequisites:

All hexadecimal starts with #
The size of hexadecimal is 2. No 0x111 or '0xbbb'


texts: Can a Lithium Polymer battery charging circuit on Arduino boards also charge Lithium Lion batteries?

texts:
I have a project that the form factor of 18650 batteries works well for. The board I'm using is a esp32 based board with built in battery charging:
https://www.amazon.com/gp/product/B072HBW53G/ref=ppx_yo_dt_b_asin_title_o00_s02?ie=UTF8&psc=1

I've heard that the flatpack type Lithium Polymer batteries have built in over charge circuitry. Is this generally true?
Can I directly charge a 18650 battery from Arduino type boards that have built in battery charging functionality?

EDIT:  So from looking at the battery circuit schematic from the Wemos link and the board itself it uses a TP4054 "Standalone Linear Li-lon Battery Charger with Thermal Regulation in SOT".  And since I can confirm the board works with 3.7V batteries and my 18650 is a 3.7V type I think I'm good.

EDIT:  Found info on this board:
http://www.raspberrypiwiki.com/index.php/WEMOS_ESP32_Board_with_OLED

Also by "Arduino type" boards I mean any popular micro controller board that has a battery charging function such as the Adafruit feather boards.

EDIT:  To clarify:
Reading here Li Poly and Li Ion batteries are essentially the same
https://scottiestech.info/2015/06/21/lithium-polymer-vs-lithium-ion-batteries-whats-the-deal/

I believe the board is a Wemos D32 with an attached display though I can't find any specific info on this exact board.
https://wiki.wemos.cc/products:d32:d32#technical_specs

I basically want to know if I can charge a Lithium Ion battery with this type of board.  As this is potentially a safety concern I wanted to ask some experts.


texts:
I am using atmega 2560 and SIM808. When I send an AT command to SIM808 it returns correctly. But sometimes I have seen that SIM808 returns the same AT command. Sometimes it occurs due to lack of power in SIM808 and due to Serial problem. But another time I have seen that, power and Serial are ok but it returns the same AT command.
Why this type of problem occurs ?


texts: Load cell weight distribution on rectangular shape instead of square

texts:
I have built a simple scale using 4 so called 50kg load cells.

They are connected in a bridge and mounted on wooden feet of a square shaped box. All as a proof of concept which worked quite ok. The readings are all OK and deviation of +/- 2kg is totally acceptable for my project. I followed this discussion which also explains how the connection should be made properly using 4 cells.
How to get weight data from glass electronic bathroom scale sensors?
Now I want to keep the load cells on the feet but change the shape of the scale and instead of a square use a rectangle with the following sides.

In such a form a weight distribution will not be centered all the time. The object to be weighed can shift to the right or to the left.

Will this affect the measurements in a negative way or will the HX711 controller still take care of it and show the correct results?
Will the measurements still be correct using 4 cells? If not what would be the proper way of weighing a rectangular shaped load?
Would it more appropriate to measure the load with 2 cells on the right and two cells on the left and then sum it up?


texts: sizeof() on custom library constructor returns wrong result

texts:
I made a custom library (let's call it DigitalOutput.h) to learn a bit about librairies and to simplify my work. Here is the basic constructor in the .h file:

DigitalOutput(uint8_t pin);

Here is the code in the .cpp file :

DigitalOutput::DigitalOutput(uint8_t pin)
{
    _pin    = pin;
    _status = LOW;
    pinMode(pin, OUTPUT);
}

So very simple stuff. Now, in my program, I call the function the usual way:

DigitalOutput LED(7); // pin #7 will be configured
                      // as an output pin to control the LED

Now the issue comes when I create an array and then use the sizeof() function.
Here is the code from my program (using an Arduino Mega):

DigitalOutput   LED_array[] = {22,23,24,25,26,27,28,29,
                               30,31,32,33,34,35,36,37};

So, the array contains 16 elements. But when I do for instance...

#define         LED_NUMBER    sizeof(LED_array)
//...
void setup(){
    //...
    Serial.println(sizeof(LED_array));
    Serial.println(LE_NUMBER);
}

...I get 160 as a result in both cases instead of 16...

So I end up doing a weird #define LED_NUMBER sizeof(LED_array) / 10 in order to get the proper result which is then used throughout the program. Any idea of why this isn't working right?


texts: sending multiple signals at the same time, with short delay

texts:
Is it possible to do something like this: send a HIGH signal to an output pin, after a 0.33s delay arduino sends HIGH signal to another pin, and after another 0.33s delay, arduino sends signal to third pin. There has to be 90 seconds long high signal for each pin, but with 0.33s delay between each other.

Sooo something like this; start of the high signal on left, stop on right side:

pin1: 0 ...... 90.00
pin2: 0.33 ... 90.33
pin3: 0.66 ... 90.66

Is there a way to solve this?


texts: Interfacing 9-Axes Motion Shield with RPi and WiFi Shield

texts:
I recently purchased the Arduino 9-Axes Motion Shield. I have two questions:

Q1. The official Arduino page says that the shield doesn't have any external power source and can only be powered up by stacking on top of an Arduino board. How can I use this shield with a Raspberry Pi?

Q2. A page here shows that it has support for the Ethernet Shield but doesn't mention WiFi shield anywhere. Does this mean that I cannot use my WiFi shield with it? I plan to stack the 9-axes shield on top of the WiFi shield which in turn is stacked over Arduino Uno.


texts:
I have arduino pro mini 5V, 16M ATMega328 and CP2102 USB to TTL. I've wired them like this:

When I try to upload a sketch to the arduino board I'm getting the following error:

avrdude: stk500_getsync(): not in sync: resp=0x00

The board type and the serial port are correct. The sketch also compiles successfully and I've installed the CP2102 drivers. I've noticed that even if I unplug all wires from the arduino board(and just leave the cp2102 connected to the PC), I'm getting the same error again. I'm using Windows 7.

Anyone else encountered the same issue?


texts: Can we use yx5300 to play audio from a file in Arduino?

texts:
I want to play a file that I have in my USB device through a yx5300 mp3 module.

I have a file in my USB device at path Music/hello.mp3. I want to play this file using the yx5300 module or some other module, if available.

I have already read this file using a shield. I want to pass the data to the yx5300.


texts:
I am just starting to learn bitwise operands and here is my question. To do this:
pinMode (13, OUTPUT);
digitalWrite (13, HIGH);

bitwise I can do like this:
DDRB |= B00100000;   //set PIN13 as OUTPUT
PORTB |= B00100000;  //set PIN13 HIGH

but how I can do this:
analogWrite(9, 200);

I know how to convert DEC numbers to BIN, but how to send this number to PWM PIN? I cannot find any good example in web..
Thank you!


texts: Display upTime using `millis()` - Arduino Uno

texts:
I want to use the following function to display MCU's uptime, but after several hours I get error.
void uptime(char *ret_clk)
{
  byte days = 0;
  byte hours = 0;
  byte minutes = 0;
  byte seconds = 0;

  int sec2minutes = 60;
  int sec2hours = (sec2minutes * 60);
  int sec2days = (sec2hours * 24);

  unsigned long time_delta = millis() / 1000UL;

  days = (int)(time_delta / sec2days);
  hours = (int)((time_delta - days * sec2days) / sec2hours);
  minutes = (int)((time_delta - days * sec2days - hours * sec2hours) / sec2minutes);
  seconds = (int)(time_delta - days * sec2days - hours * sec2hours - minutes * sec2minutes);

  sprintf(ret_clk, "%01dd %02d:%02d:%02d", days, hours, minutes, seconds);
}

after 2:55 hours I got a correct answer : 0d 02:55:27
also after 4 hours, a correct answer : 0d 04:06:44
but roughly after 12 hours i get an error: 1d 02:01:27
and after roughly 20 hours I get : 2d 23:74:26
What is wrong in uptime ?


texts:
How can I use delimiter/split serial input in a loop function? I want to use each word from the input and check a database, to check availability.

#include SoftwareSerial.h>
#define MAX_WORD_LENGTH 15

char messageArray[5][MAX_WORD_LENGTH + 1];
SoftwareSerial BT(10, 11);
String command = "";
char message[] = "";

void setup() {
  BT.begin(9600);
  Serial.begin(9600);
  while (BT.available()) {
    delay(10);
    char c = BT.read();
    command += c;
  }

  if (command.length() > 0) {
    Serial.println(command);
    char message[] = {command};
    for (int i = 0; i < 5; i++) {
      // you can 'reset' the array by writing a null to the first element of each
      messageArray[i][0] = '\0';
    }
    sscanf(message, "%s %s %s %s %s", messageArray[0], messageArray[1], messageArray[2], messageArray[3], messageArray[4]);
    for (int i = 0; i < 5; i++) {
      Serial.println(messageArray[i]);
      delay(1000);
    }
  }
}

void loop() {
  for (int i = 0; i < 5; i++) {
    // you can 'reset' the array by writing a null to the first element of each
    messageArray[i][0] = NULL;
  }
  command = "";
}


texts:
What kind of function can I use to know how many elements are in an array char?

sizeof() gives the number of 'spaces' available so it doesn't work for me.


texts: Can I make a 455Khz Sine Wave with the Arduino UNO?

texts:
Can any one help me, I need to make a sine-wave of 455Khz for use in aligning a Super 7 - AM Radio.

I looked into buying a function generator but I have an Arduino UNO. Can this do the tasks?


texts: How can I reduce speed of motor with motor shield?

texts:
I'm using Arduino and Adafruit to control 4 motors for a little robot.

I have this code example:

#include <AFMotor.h>

AF_DCMotor motor1(1, MOTOR12_1KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor2(2, MOTOR12_1KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor3(3, MOTOR12_1KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motor4(4, MOTOR12_1KHZ); // create motor #2, 64KHz pwm

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Motor test!");

  motor1.setSpeed(200);     // set the speed to 200/255
  motor2.setSpeed(200);     // set the speed to 200/255
  motor3.setSpeed(200);     // set the speed to 200/255
  motor4.setSpeed(200);     // set the speed to 200/255
}

void loop() {
  Serial.print("tick");

  motor1.run(FORWARD);      // turn it on going forward
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);
  delay(1000);

  Serial.print("tock");
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(BACKWARD);
  motor4.run(BACKWARD);
  delay(1000);

  Serial.print("tack");
  motor1.run(RELEASE);
  motor2.run(RELEASE);
  motor3.run(RELEASE);
  motor4.run(RELEASE);
  delay(1000);

}

I want to reduce speed, because now is very fast. If I change setSpeed, the motor have no more force and don't run or not good. Do you know what I'm doing wrong?

Thanks
Best regards


texts: Reading and sending data from a micro SD card using Micro SD card adapter without using buffer

texts:
Actually,  I am trying to get data that appears in a .wav file, but I got the problem that it is not as fast as I need because, looking around the SD library I found that most of the bits are saved into the buffer and when the buffer is filled its information is sent.
However, I do not want it to happen. I just need the bits to get readed and next to be sent as soon as possible witout saving in the buffer.
Do you know if is it actually possible, to modify the SD library to change the transmition's parameters because As I wrote previously I do not want the buffer to be used.


texts: MPU9150 (JEFF LIB) + FIFO_OVERFLOW INTERRUPT + SERIAL PRINT

texts:
Overflow enthusiasts!

I am trying to log accelerometer and gyro data using Serial.print. I have enabled the FIFO_Overflow interrupt. Whenever I log data, the serial port freezes. I am suspecting an interrupt issue while I am using Serial.print. Is there any way to get continuous data for debugging purposes? I know that the Serial library can affect interrupts and wonder whether you guys could help me a little bit ?

#include "Wire.h"
#include "I2Cdev.h"
#include "MPU9150.h"
#include "helper_3dmath.h"

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
MPU9150 accelGyroMag;
#define LED_PIN 13
volatile boolean state_fifo_int = false;
uint16_t fifo_count;
uint8_t fifo_buffer[8];
int16_t acc_temp[3];
int16_t gyro_x;

void setup(){
    // join I2C bus (I2Cdev library doesn't do this automatically)
    Wire.begin();
    // initialize serial communication
    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
    // it's really up to you depending on your project)
    Serial.begin(115200);
    // initialize device
    Serial.println("Initializing I2C devices...");
    accelGyroMag.initialize();
    // verify connection
    Serial.println("Testing device connections...");
    Serial.println(accelGyroMag.testConnection() ? "MPU9150 connection successful" : "MPU9150 connection failed");
    // configure Arduino LED for
    pinMode(LED_PIN, OUTPUT);
    attachInterrupt(0,fifo_int,CHANGE);
}

void fifo_int() {
  state_fifo_int = true;
}

void loop(){
  while(!state_fifo_int) {
    accelGyroMag.setIntFIFOBufferOverflowEnabled(true);
    // enable fifo_interrupt
    accelGyroMag.setFIFOEnabled(true);
    accelGyroMag.setAccelFIFOEnabled(true);
    accelGyroMag.getXGyroFIFOEnabled();
    accelGyroMag.getAccelFIFOEnabled();
    fifo_count = accelGyroMag.getFIFOCount();
    accelGyroMag.getFIFOBytes(fifo_buffer,8); // fill in fifo bytes
    acc_temp[0] = (((int16_t)fifo_buffer[0]) << 8) | fifo_buffer[1];
    acc_temp[1] = (((int16_t)fifo_buffer[2]) << 8) | fifo_buffer[3];
    acc_temp[2] = (((int16_t)fifo_buffer[4]) << 8) | fifo_buffer[5];
    gyro_x = (((int16_t)fifo_buffer[6]) << 8) | fifo_buffer[7];
    Serial.print((float)acc_temp[0]/16384);
    Serial.print("  ");
    Serial.print((float)acc_temp[1]/16384);
    Serial.print(" ");
    Serial.print((float)acc_temp[2]/16384);
    Serial.print(" ");
    Serial.println(gyro_x);
   }
   accelGyroMag.setIntFIFOBufferOverflowEnabled(false);
   // disable fifo_interrupt
   accelGyroMag.resetFIFO();
   state_fifo_int = false;
}

The library for the MPU9150 is by Jeff Rowberg.


texts: ESP8266 library: 2 requests received instead of 1

texts:
I have a strange issue with my sketch using WiFiEsp.h library from https://github.com/bportaluri/WiFiEsp

When i send 1 request to my ESP8266 from my browser as http://192.168.0.25
, it seems that my ESP8266 receives 2 requests and run 2 times. See the sketch here and Serial Termninal:

void loop()
{
  // listen for incoming clients
  WiFiEspClient client = server.available();
  if (client) {
    Serial.println("New client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected())
    {
      if (client.available())
      {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          Serial.println("Sending response");

          // send a standard http response header
          // use \r\n instead of many println statements to speedup data send
          client.print(
            "HTTP/1.1 200 OK\r\n"
            "Content-Type: text/html\r\n"
            "Connection: close\r\n"  // the connection will be closed after completion of the response
            "\r\n");
          client.print("<!DOCTYPE HTML>\r\n");
          client.print("<html>\r\n");
          client.print("Hello World!\r\n");
          client.print("</html>\r\n");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(10);

    // close the connection:
    client.stop();
    Serial.println("Client disconnected");
  }
}

Serial temrinal:

[WiFiEsp] Initializing ESP module
[WiFiEsp] Initilization successful - 2.0.0
Attempting to connect to WPA SSID: Numericable-6010
[WiFiEsp] Connected to Numericable-6010
You're connected to the network
SSID: Numericable-6010
IP Address: 192.168.0.25

To see this page in action, open a browser to http://192.168.0.25

[WiFiEsp] Server started on port 80
[WiFiEsp] New client 0
New client
GET / HTTP/1.1
Host: 192.168.0.25
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://192.168.0.25/
Accept-Encoding: gzip, deflate
Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7

Sending response
[WiFiEsp] Disconnecting  0
Client disconnected
[WiFiEsp] New client 1
New client
GET /favicon.ico HTTP/1.1
Host: 192.168.0.25
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Accept: image/webp,image/apng,image/*,*/*;q=0.8
Referer: http://192.168.0.25/
Accept-Encoding: gzip, deflate
Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7

Sending response
[WiFiEsp] Disconnecting  1
Client disconnected

Please, could you explain why 2 clients connected ? How can i disconnect just after the first one ?


texts:
While trying to read RPM from a computer fan using the 4-wire protocol, I am getting strange readings. +12 and GND from the fan are connected to a power supply, and the tachometer to the PIN-0 or a Teensy 3.2.

I wrote code to read the tachometer pulse using the internal pull-up and interrupts. The strange thing happening is that the number of recorded revolutions is increasing as I manually slow the fan using my fingers.

Here is the code :

#include <avr/io.h>
#include <avr/interrupt.h>
#include <elapsedMillis.h>

const int fanPulse = 0;
volatile long half_revolutions;
elapsedMillis timeElapsed;

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

  pinMode(fanPulse, INPUT_PULLUP);
  attachInterrupt(fanPulse, rpm_fun, FALLING);

  half_revolutions = 0;
  // analogWriteFrequency(20, 25000); // Teensy 3.0 pin 3 also changes to 375 kHz
}

void rpm_fun() {
  half_revolutions++;
}

void loop() {
  if (timeElapsed < 1000)
    return;

  Serial.printf("%d revolutions in %d miliseconds\n", half_revolutions / 2, (unsigned long)timeElapsed);

  timeElapsed = 0;
  half_revolutions = 0;
}

Here is the strange output :

0 revolutions in 1000 miliseconds  // Start
0 revolutions in 1000 miliseconds
82 revolutions in 1000 miliseconds
394 revolutions in 1000 miliseconds  // "normal" reading
412 revolutions in 1000 miliseconds
576 revolutions in 1000 miliseconds
456 revolutions in 1000 miliseconds
554 revolutions in 1000 miliseconds
585 revolutions in 1000 miliseconds
799 revolutions in 1000 miliseconds  // Slowing the fan
712 revolutions in 1000 miliseconds
691 revolutions in 1000 miliseconds
683 revolutions in 1000 miliseconds
625 revolutions in 1000 miliseconds
531 revolutions in 1000 miliseconds
239 revolutions in 1000 miliseconds
0 revolutions in 1000 miliseconds
0 revolutions in 1000 miliseconds  // End


texts: how to send data to Adafruit Bluefruit Feather (32u4) over bluetooth?

texts:
Sup yo.

I have my Adafruit Bluefruit Feather all wired up.  It's lovely.  I've got it responding to commands over the USB serial, activating an array of octocouplers.  It's terrific.  Here's the thing though.  I need to talk to it wirelessly.

I can only pair it (MacOS) the Adafruit Bluefruit LE Connect app.  It doesn't show up in my Bluetooth preference pane.

$ ls /dev/tty.*  shows /dev/tty.Bluetooth-Incoming-Port and the Arduino IDE can see it.  Unfortunately the word Incoming is right there in the middle of that port name.  Sending commands through the Arduino serial monitor doesn't seem to do anything.

The Bluefruit connect app appears to be able to send commands over something called UART but my board doesn't respond to the stuff that works over USB serial.

How do I talk to this board over Bluetooth?


texts:
I am lakshman a mechanical engineer,i have a question that is there any possibility of connecting ACCELEROMETER + ARDUINO UNO + GSM module together???

so that i can take the output value from Accelerometer so that to make a call to a preprogrammed number???

Plz help me.

Thank you.


texts: OTA updating the ESP32 from a separate server

texts:
I have an ESP32 project which I'd like to be able to update OTA. The trouble is that it is in deep sleep for approximately 15 minutes before waking up, connecting to WiFi sending an MQTT packet then going back to sleep.

I would like to be able to have a webpage hosted on a Raspberry Pi with a repository of datestamped .bin files that the ESP32 can connect to, check it's current version against the available options, if there is an applicable update, go through the standard OTA update protocol, or if there is no new available version, don't check again for 24 hrs.

How do I go about this?


texts:
I have an ATtiny hooked up to two line scan modules. I'm sending digital signals to the line scan modules then receiving the analog output and storing it in an array. I have an if statement that will make the LED on the ATtiny programmer blink when the number are below a certain range (meaning that lens is covered).

Here is my code:

#include <SoftwareSerial.h>
const int rx=0;
const int tx=1;

SoftwareSerial mySerial(rx,tx);
int CLK = 2;
int SI = 1;
int Aout = A3;
int Aout1 = A2;

int LED = 0;

int pixelsArray[128];   //Array to hold the values of the individual pixles.
int pixelsArray1[128];

 void outputPixels()
{
  for(int j = 0; j < 128; j++)
  {
    digitalWrite(LED, LOW);

    if(pixelsArray[j] < 100)
    {
      digitalWrite(LED, HIGH);
      delay(500);
      digitalWrite(LED, LOW);
      delay(500);
    }
  }
}

The problem that I am having is that when I test my code with one line scan module it works just fine. You will notice that in the readPixels() I have the statement pixelsArray1[i]=analogRead(Aout1); commented out. However, when I try to use it with two the LED start blinking regardless of how much light is hitting the line scanner.

The strange thing is that EVEN when I comment out the digitalWrite(LED, HIGH); statement in the outputPixels() method...THE LED STILL BLINKS!!!

Since the ATtiny does not support URT and can't use the console in Arduino I have no idea how to debug this. Does anyone here have any clue what is wrong?

Here is the datasheets

ATtiny: http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf

ATtiny Programmer: https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/?_ga=1.59946280.467360091.1464906372


texts: How to set the sampling frequency in Arduino without using a delay

texts:
I am reading an ECG signal using a single lead heart rate monitor. What I know is that when I use delay(15) it means that I am getting 66.67 readings in a second which corresponds to the sampling frequency. I want to set the sampling frequency to 250. This can be done by introducing delay(4).

What I really need is to set the sampling frequency to 250 Hz without introducing a delay in the code because I am acquiring ECG data in real time. Also, I am sending the data to python for processing and the delay will affect the sampling frequency in the time domain analysis.

any detailed solution or code ??

PS. I am using Arduino UNO

Code:

#define SERIAL_BUFFER_SIZE 8192
#include <SoftwareSerial.h>
unsigned long Time;
void setup() {

  // initialize the serial communication:

  pinMode(10, INPUT); // Setup for leads off detection LO +
  pinMode(11, INPUT); // Setup for leads off detection LO -
  Serial.println("CLEARDATA"); //clears up

  Serial.println("RESETTIMER"); //resets timer to 0

  Serial.begin(115200);

}

void loop() {
  if((digitalRead(10) == 1)||(digitalRead(11) == 1)){
   Serial.println('!');
  //  continue;
  }
  else{
   /*
     // send the value of analog input 0:
     int idata = analogRead(A0);
  //  float data = (idata*3.3)/1023;
      Serial.println(idata);
*/
  int sensorValue = analogRead(A0);
  float voltage = sensorValue * (3.3/1023.0);
  Serial.println(voltage);
  }
  //Wait for a bit
    delay(4);
}


texts:
I just bought a WiFi shield and I cannot connect to my wireless network (WPA2).

I used the sketch from the Arduino site for connecting to WPA network and put my SSID and password on but it doesn't connect (I know the credentials are correct as I used my phone to connect with these WiFi credentials).
When I read the serial monitor it just keeps trying to connect. The WiFi-shield board error light is red
I checked my network settings and my block level is at is lowest (NAT only).

Why can't I connect?


texts: Unknown errors compiling BreakoutST7735 128*128

texts:
please tell me how should I solve these errors?
#error ENABLE_EXTENDED_TRANSFER_CLASS must be set to 1 in SdFat SdFatConfig.h
#error FAT12_SUPPORT must be set to 1 in SdFat SdFatConfig.h
thanks


texts: Can UNO log more PCB 353b33 accelerometer data points compared to TDS3014B oscilloscope?

texts: I'm currently recording data points from an analog accelerometer(PCB 353b33) using a TDS3014B oscilloscope which has Record Length of 10,000 points at a Sample Rate 1.25 Ga/s. I'm want to record more data points, would it be possible to use UNO as a data acquisition device and record much higher data points than the oscilloscope(>> 10,000)


texts: What happens if an interrupt is triggered while sending data via serial?

texts:
I would like to use an inertial sensor to measure acceleration and send the results to an Android app using a serial communication with a bluetooth Mate Gold module. The sensor provides a data ready interrupt which notifies Arduino-Mega that a new value is stored in a register of the module. The output data rate can be modified during the configuration of the sensor.
I want the information to be sent at a 10 Hz rate to the bluetooth module.

Is an interrupt at 400Hz capable of compromising the integrity of a 50 bytes long message sent at 10 Hz with a baudrate of 9600?
If yes, which approach would you recommend to correctly send the data?

Edit:
I'm using the following formula to compute the amount of time required to send N chars.

bytes x bits_per_character / bits_per_second
N x (8+2) / 9600 = N/960 secs

For N = 52:

52/960 = 0.054 secs = 54 ms

So theoretically, I can send a 54 char-long message at 18Hz with a baudrate of 9600.

Edit2
I can use the hardware serial or the Software Serial interface.


texts: Can I safely power my UNO and DC motors with the 5v1A and 5v2.1A ports on a USB charger?

texts:
I have USB charger battery pack with two output ports (Fremo C510).  One is marked as 5 volts 1 amp, and the other as 5 volts 2 amps.

I'm building a toy robot and would like to run the UNO off of one of those ports, and the motors off of the other.

Can I safely do that?  I have two main concerns:

Can I safely power the arduino with that current?
If I power both the motors and the arduino from that source (two usb ports connected to the same battery), will I still have to worry about spikes from switching the motors on and off?  I don't know how those ports are wired to the actual battery inside.


texts:
I have a problem with the Servo library.

I need to read a PPM signal and create a PWM signal of each channel. The problem is that PPM has a higher resolution than PWM so I want to use the 16 bit Timer1 for reading PPM. However the Servo library that writes the PWM signal also uses Timer1.

Is it possible to generate a PWM signal with 8 bit / Timer2? And has someone made an example, or an explanation about, how to do that?


texts: How to "implement" an Arduino prototype?

texts:
I am starting with Arduinos, coming from the world of Linux (with the RPi as a bridge) and after having tested some setups I now wonder where to go next in implementation.

What I am trying to understand is whether it is recommended (time and cost-wise)

to create a standalone, circuit-board based version of whatever I prototyped on the breadboard, with a micro-controller with connections trimmed down to what is needed for that specific setup?
or rather just look at neatly packaging the Arduiono with the breadboard and wires in a case?

I expect to build 5 or 6 of the same simple setups (to put in various places in my house).

Note: there is a similar question (with almost the same title) but it deals with the legal aspects of commercializing a setup.


texts: WifiNINA WebServer not receiving connections

texts:
I use a MKR 1010 (firmware 1.2.1), download WifiNINA library (version 1.3.0) and started to play with it.

I can connect to my Wifi network, and WifiNINA library examples such a WifiPing (which repeatedly pings www.google.com) works fine.

However, I can't get any of the server examples (e.g. WifiWebServer) to work.

I can see that the board connects to the network and gets an IP and the Serial monitor is printing this :

09:11:15.989 -> SSID: OfficeNet
09:11:15.989 -> IP Address: 192.168.1.44
09:11:15.989 -> signal strength (RSSI):-36 dBm
09:11:15.989 -> To see this page in action, open a browser to http://192.168.1.44

But if I browser to http://192.168.1.44, I never get any answer.

The loop code is just from the example :

void loop() {
  WiFiClient client = server.available();   // listen for incoming clients

  if (client)
  {                             // if you get a client,
    Serial.println("new client");           // print a message out the serial port
(...)
  }
  // close the connection:
  client.stop();
  Serial.println("client disonnected");
}

I am never getting inside the if client()loop ("new client" never printed).

Any suggestions?


texts:
I'll start by saying that the goal here is to have a hand/distance detection device. Basically touch-less button.
I managed to get it working with a simple 2-pin IR emitter and 2-pin IR detector using analog read from the detector to trigger an event. The problem is that I get interference from the sun on bright days.
Is there a way to pulse the emitter at a specific frequency and have the detector activate only on that frequency and keep the 2-pin setup?
One solution I have been leaning towards is changing the IR detector to a IR decoder and basically treat it as a remote control but I can't see a way to detect distance using this method.
I am also open to any other ideas on getting something like this to work, without IR or ultrasonic.
Thanks.


texts: 20x4 LCD Error. 8 black boxes to the left on row 3 and 4

texts:
20x4 I2C conected LCD. 8 black boxes to the left on row 3 and 4.
What could the problem be?


texts:
for (byte i = 0; i < mfrc522.uid.size; i++)
  {
    Serial.print(mfrc522.uid.uidByte{i} < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte{i}, HEX);
    content.concat(String(mfrc522.uid.uidByte{i} < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522.uid.uidByte{i}, HEX));
  }

I use this code to get UID of an RFID card, but the error "expected ')' before '{' token" comes out. Does anybody know how to solve this problem?


texts: Is there an Arduino Simulator or Emulator that runs on OS X?

texts:
Is there an Arduino Simulator or Emulator or cross-compiler to native Mac executable that runs directly under Mac OS X, and does NOT require a Windows or Linux VM or an active internet connection for running in the cloud?

There are previous questions here on similar topics, but they do not seem to address exactly this particular use case subset.


texts: Stepper motor just oscillates with arduino and L293D

texts:
I am trying to control my stepper motor using arduino duemilanove, with L293D as H-bridge. I use a NEMA 17, stepper motor 42BYGH-036B I have used both the default example program from arduino IDE, and also from; http://www.electronicshub.org/stepper-motor-control-using-arduino/

But in both cases, The motor just oscillates, without going for rotation.

The following is the connection, I have been using;


texts:
Just bought an ESP8266 module to try it using my arduino uno R3. I have connected my WIFI module correctly, anyways evenb if i disconnect it, the error occur.

While trying to upload the WIFI (connect with wpa) sketch i get several errors.

First i tried uploading the hole sketch, i got those errors:

/usr/share/arduino/libraries/WiFi/WiFi.cpp: In member function ‘uint8_t* WiFiClass::macAddress(uint8_t*)’:
/usr/share/arduino/libraries/WiFi/WiFi.cpp:112:1: error: unable to find a register to spill in class ‘POINTER_REGS’
/usr/share/arduino/libraries/WiFi/WiFi.cpp:112:1: error: this is the insn:
(insn 35 25 26 2 (set (reg:QI 23 r23)
    (mem/c:QI (plus:HI (reg/f:HI 28 r28)
            (const_int 2 [0x2])) [3 S1 A8])) /usr/share/arduino/libraries/WiFi/WiFi.cpp:110 28 {movqi_insn}
     (nil))
/usr/share/arduino/libraries/WiFi/WiFi.cpp:112: confused by earlier errors, bailing out

After that i tried to only import just the libraries and try to compile it. Even with this method i get errors

Code

#include <WiFiServer.h>
#include <WiFiClient.h>
#include <WiFi.h>

error:

In file included from /usr/share/arduino/libraries/WiFi/WiFiServer.h:8:0,
                 from sketch_oct20b.ino:1:
/usr/share/arduino/hardware/arduino/cores/arduino/Server.h:4:29: error: expected class-name before ‘{’ token
In file included from sketch_oct20b.ino:1:0:
/usr/share/arduino/libraries/WiFi/WiFiServer.h:14:3: error: ‘uint16_t’ does not name a type
/usr/share/arduino/libraries/WiFi/WiFiServer.h:17:22: error: field ‘uint16_t’ has incomplete type
/usr/share/arduino/libraries/WiFi/WiFiServer.h:18:24: error: ‘uint8_t’ has not been declared
/usr/share/arduino/libraries/WiFi/WiFiServer.h:20:11: error: ‘size_t’ does not name a type
/usr/share/arduino/libraries/WiFi/WiFiServer.h:21:11: error: ‘size_t’ does not name a type
/usr/share/arduino/libraries/WiFi/WiFiServer.h:22:3: error: ‘uint8_t’ does not name a type
/usr/share/arduino/libraries/WiFi/WiFiServer.h:24:9: error: ‘Print’ has not been declared
/usr/share/arduino/libraries/WiFi/WiFiServer.h:18:42: error: ‘NULL’ was not declared in this scope

I can just figure out some syntax errors, but my c is not good enough to understand much of it.

Can anyone tell me what am i doing wrong and show me how it will be done?


texts: Use Arduino Uno digital pins instead of ESP8266

texts:
I would like to know if this is possible.

I am using an ESP8266-ESP01, which only has 2 digital pins. I have a project that needs 3 digital pins so I have planned to use my Arduino, so I can use more digital pins. My plan is instead of plugging the sensor in the GPIO1 of the ESP8266, I could somehow plug it in the Arduino digital pins and the data would just be transferred to the ESP8266 and be uploaded to an online cloud.

I can read the sensor data in the Arduino but I don't know how to transfer the data to the ESP8266 so the wifi module would just receive it and send it to the online cloud.

If anyone can help me to get some idea specifically on sending the data from Arduino to the ESP and receiving the data from the Arduino.

Thank you.


texts: Why should a pin be set as an input if it can read input when set as output?

texts:
I recently created a circuit to read the value from two sets of buttons using only two analog pins. It involves setting one pin HIGH and reading the input on the other pin and then swapping. With both pins set to OUTPUT I can still read in values with analogRead() without having to keep switching pin modes.

My question is why is that the case? What is the point of setting a pin to INPUT if OUTPUT can still read in values? Are there any disadvantages of doing so?


texts:
I am making a bike alarm for my bike. I haven't started yet.
Basically, I'm thinking of a pin to be connected to the metal post (to which the bike is locked.) I want to detect if that connection (to the ground via the metal post) is broken.
Is that possible?


texts: Is there a equivalent to #define DEBUG 0 declare by VS2017 with VisualMicro (arduino) project?

texts:
Especially on ESP32*/8266, when you select debug (debug/release) :  as a target, VisualMicro detect it and start the simple debugger (without JTAG).

Do you know if when target is debug, is there a #define created somewhere by VS that could be use with #ifdef for example?

*ESP32 WROOM not ESP32 WROVER able to debug through USB double chanel


texts: Uno to NodeMCU Serial Connection Problem

texts:
This is my first project with any sort of development board and it has been a blast so far.

I am running into some issues, however, while trying to send serial data from my Uno to a NodeMCU board.

I have the following connections:

Uno Rx to NMcu Tx

Uno Tx to NMcu Rx

Uno GND to NMcu GND

microUSB from computer to power NMcu

usb from computer to power Uno

EDIT: after some suggestions, I have also tried the following.

Uno DigitalPin 5 to NMcu D6

Uno DigitalPin 6 to NMcu D5

Uno GND to NMcu GND

microUSB from computer to power NMcu

usb from computer to power Uno

With the following code:

// UNO sender Code
#include <SoftwareSerial.h>
SoftwareSerial toESP(0, 1); //Rx, Tx (also tried 5,6)

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

void loop()
{
  Serial.println("sending");
  toESP.println("message from Nano");
  delay(1000);
}

// NodeMCU receiver code
#include <SoftwareSerial.h>
SoftwareSerial fromNano(3, 2); //Rx, Tx (also tried D5, D6)

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

void loop()
{
  if (fromNano.available())
  {
    char inChar = fromNano.read();
    Serial.print(inChar);
  }
  else {
    Serial.println("not available");
  }
  delay(2000);
}

I can pull up a serial monitor from both and see the UNO sending data (the TX led also blinks on the uno).

The NodeMCU code never satisfies the fromNano.available condition.

Is there anything I am overlooking that is causing this not to work? I've attached a picture of my connections as well.

Any help is much appreciated.


texts: CAN bus libraries for STM32F103 in Arduino IDE

texts: I need to implement CAN communication between two STM32F103 microcontroller boards. I am finding it difficult to get libraries for the same. Can anyone please suggest where I can find working CAN bus libraries for STM32F103?


texts: How can I run two loops simultaneously on an Arduino Uno?

texts:
I'm new to Arduino and I have two devices that I'm trying to control:

A RGB LED light strip that can change colors
A light sensor that can detect the ambient light level

What I'd like to do is have the LED strip continuously cycle through a rainbow of colors, and the light sensor will adjust the brightness of the LED strip based on the ambient light level. Here are the two pieces of code by themselves, which I've tested in isolation and confirmed that they work properly:

LED strip:

j = (j + 1) % 256; // current iteration of the light cycle

// set the strip color
for(int i=0; i< strip.numPixels(); i++) {
  strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}

// display the new colors and wait 20ms before the next cycle
strip.show();
delay(20);

Light sensor:

sensors_event_t event;
tsl.getEvent(&event); // get a light measurement
strip.setBrightness(event.light); // set the brightness of the LED strip

The problem is that the light sensor takes anywhere from 100ms to 600ms to get a reading, and tsl.getEvent(&event) is a blocking call, so the end result is that the LED strip updates way too slowly. I would need to run the two side by side so that the light sensor read does not block the LED strip update. Any idea how I can accomplish this?


texts: WiFi module ESP8266-01 for Arduino not working

texts:
I am new to using Arduino just bought my first one yesterday, and I also got an WiFi module. The Arduino I got is another brand but should be the same as the Arduino Uno rev 3 and I got the ESP8266-01 wifi module.

I've tried doing some simple examples projects following some YouYube videos, and all those have worked without problem.

What I am trying to create is a simple magnetic door switch. When it's opened I get a signal to my computer. Getting the magnetic door switch wired with the Arduino and getting an LED to light up when the magnetic switch opened worked without problem.

But to set up the wifi module, I can't get it to work.

I have spent hours and hours watching tutorials reading all I can find to trying everything to get this to work, but no luck.

I don't know If I am doing something wrong (probably) or if something is broken.

These are the instructions I am trying currently.

Video of my Arduino setup

For the Arduino board I use 12v DC in and USB from my PC.

Code:

#include "Arduino.h"
#include "ESP8266.h"

#include "SoftwareSerial.h"
SoftwareSerial  ConsoleOut(8, 9);

#define SSID  "ASUS"
#define PWD   "tmpPassword"

void setup() {
  char  *ipAddress, ap[31];

  WiFi.reset(WIFI_RESET_HARD);
  WiFi.begin(9600);
  ConsoleOut.print("flag2");
  if (WiFi.join(SSID, PWD) == WIFI_ERR_OK) {
    ipAddress = WiFi.ip(WIFI_MODE_STA);
    ConsoleOut.print(F("\n\rIP address:"));
    ConsoleOut.print(ipAddress);
    ConsoleOut.print(':');
    ConsoleOut.print("flag1");
    if (WiFi.isConnect(ap))
      ConsoleOut.println(ap);
    else
      ConsoleOut.println(F("not found"));
  } else
    while (1);
}

void loop() {
  if (WiFi.connect((char *)"www.google.co.jp", 80) == WIFI_ERR_CONNECT) {
    if (WiFi.send((const uint8_t *)"GET / HTTP/1.1\r\n\r\n") == WIFI_ERR_OK) {
      int16_t c;
      uint16_t len = WiFi.listen(10000UL);
      while (len)
        if ((c = WiFi.read()) > 0) {
          ConsoleOut.write((char)c);
          len--;
        }
    } else
      ConsoleOut.println(F("Send fail"));
    WiFi.close();
  } else
    ConsoleOut.println(F("TCP connect fail"));
  WiFi.disconnect();
  while (1);
}

Code:

Different from the example sketch is that I use 2K instead of 3K resistors for R2, R4 and 1K for R1, R3. (2K on left side in the video 1K on the right side)

The LED of the WiFi lights red constantly. I don't know what that means,  and the blue LED on the wiFi module lights up whenever I upload a sketch to the Arduino.

Thanks in advance. Any help is really, really appreciated.


texts:
How can we increase the Arduino's ADC sampling rate to 1 MHz while maintaining a 10 bit resolution? Can we change the prescaler to 16 to get 1 MHz ADC clock?

If not, what alternatives are there? Another Atmel chip that works with the Arduino library? Or any external ADC?


texts: How to read the serial data from a ATMEGA8 on a PC using Arduino?

texts:
I want to check if a device is working or not. It is a custom made PCB with a Atmega8. It was given to me along with the AVR code. How do I read the data that it sends on my laptop using a arduino, preferably a Arduino Uno?

I tried connecting the output UART pin to the Rx of the arduino, and then provided the common ground. Then I opened serial monitor on my laptop but I a m not getting anything. Is it because the PCB is damaged or am I doing it wrong?

I have the AVR code which was burned on the IC, so I can provide you with more information if you need.


texts:
I am building a project using an Arduino Nano. In it, I am using pin 3 as PWM output. However, If I supply values lower than 255 to it, the pin does not output any voltage at all.

According to this diagram, pin 3 is PWM:

I have tested it on two boards, it doesn't function on either one. It's not my sketch, either (I tested it with a simple analogWrite();).

This is the code:

void setup() {
  // put your setup code here, to run once:
  #define E1 3  // Enable Pin for motor 1
  #define E2 10  // Enable Pin for motor 2
  #define I1 4  // Control pin 1 for motor 1
  #define I2 2  // Control pin 2 for motor 1
  #define I3 A1  // Control pin 1 for motor 2
  #define I4 A0  // Control pin 2 for motor 2
}

void loop() {
  // put your main code here, to run repeatedly:
  // I use differential steering, speed is important
  analogWrite(E1, 100); // Run in full speed
  analogWrite(E2, 100); // Run in full speed

  // always go forward
  digitalWrite(I1, LOW);
  digitalWrite(I2, HIGH);
  digitalWrite(I3, LOW);
  digitalWrite(I4, HIGH);
}

What could be the reason of this?


texts:
I have seen some tutorials on ultrasonic range detector sensor.

In that, what is the meaning of the word pulseIn?


texts: I got a Arduino Uno awhile ago and it took me awhile to set up but it worked when I downloaded the IDE. This time when I bought an Arduino Nano it doesn't pop up with the driver. Doesn't show up anywhere in device manager. I've tried to reinstall the IDE to see if that would work but it didn't. What should I do/try next?


texts:
I am doing a project using Arduino UNO, cc3000 WIFI chip, micro SD card shield, and a TTL serial camera in order to make a security system that will post a picture online (not enough processing power for video) when motion is detected on the camera.

Thankfully, the hardware works after a few shortcomings, but my program seems to be taking up 97% of the Flash storage.

Also, I am looking for a better way to transfer the image than saving it 32 bits at a time and then waiting about 10 sec so the HTTP request will send it to the server.

One thing I do know is that I have tested all the hardware and those functions are working. My problem is in the logic.

Any help appreciated! (Image is around 13KB and UNO only has 2kb of dynamic memory).

My full code is here: https://www.dropbox.com/s/arxa253mxwvqtg1/HomeProj.rtf?dl=0

void loop(void)
{
    cam.setMotionDetect(true);

    while (1) {
        if (cam.motionDetected()) {
            Serial.println("Motion!");

            cam.setMotionDetect(false);
            if (! cam.takePicture())
                Serial.println("Failed to snap!");
            else
                Serial.println("Picture taken!");

            uint16_t jpglen = cam.frameLength();
            Serial.print(jpglen, DEC);
            Serial.println(" byte image");

            char filename[13];
            strcpy(filename, "IMAGE00.JPG");
            for (int i = 0; i < 100; i++) {
                filename[5] = '0' + i/10;
                filename[6] = '0' + i%10;
                // create if does not exist, do not open existing, write, sync after write
                if (! SD.exists(filename)) {
                    break;
                }
            }

            File imgFile = SD.open(filename, FILE_WRITE);
            while(jpglen > 0) {
                uint8_t *buffer;
                uint8_t bytesToRead = min(32, jpglen);
                buffer = cam.readPicture(bytesToRead);
                imgFile.write(buffer, bytesToRead);

                //Send Request
                Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);
                if (client.connected()) {
                    Serial.println("Connected!");
                    client.println("POST /upload HTTP/1.0");
                    client.println("From: Arduino");
                    client.println("Host: fierce-chamber-5675.herokuapp.com");
                    client.println("Content-Type: image/jpeg");
                    client.println("Content-Length: " + 32);
                    client.print("Connection: close");
                    client.println();
                    for(int i = 0; i < 32; i++) {
                        client.print(buffer[i], HEX);
                    }
                    client.println();
                } else {
                    Serial.println(F("Connection failed"));
                    return;
                }
                client.close();

                Serial.println(F("-------------------------------------"));
                jpglen -= bytesToRead;
            }
            imgFile.close();
            cam.resumeVideo();
            cam.setMotionDetect(true);
        }
    }
}


texts: Using an Arduino as a electrical mains switch

texts:
How do I make an electrical switch using Arduino, that when it receives signal (wirelessly or through a LAN port) to switch off it disconnects the switch and then again told to turn on turns the switch on?

The main problem I am facing is that I need to give a 5V output to turn off the transmission between two wires having voltage rating of 230V.


texts: Pro Mini not communicating with computer

texts:
when I try to upload blink program to my Pro Mini, I get this error:

avrdude stk500_getsync() not in sync resp=0x00

I've tried everything, changing the COM port, different USB cable and even another computer. Here is what I'm dealing with:

Arduino Pro Mini 328 5v 16M (Fake)

FT232RL USB to serial adapter

Nothing is connected to any pins on the Arduino, just trying to get LED to blink. I'm pretty sure the bootloader is installed, because when I hit the reset button, the LED blinks. I've tested the FTDI chip by connecting the TX and RX pins together, and it does echo in the serial monitor.
Help appreciated!


texts: SdFat: Why does the first write to the file take so long?

texts:
I have tested this problem on 6 micro-SDHC cards of 3 different types. 3 are 32-GB Sandisk, 2 are 16-GB Kingston, and 1 is 16-GB Samsung. These cards are used in data loggers and typically contain hundreds or thousands of 5-MB text files whose names are formatted like FILE1234.TXT.

The problem is that when a logger containing such a card (containing data) is started, the first write takes a long time--from 7 to 30 seconds. Opening the file (the smallest available filename) doesn't take too long. Subsequent writes don't take long. Just the first write.

Now, the plot thickens: this delay can be eliminated by first opening FILE0000.TXT and immediately closing it. Further, once this is done, that disk is never affected by this delay again. This has happened with each of the disks.

Here is some minimal code demonstrating the issue:

#include <SdFat.h>
SdFat sd;
SdFile file;

void setup(){
  Serial.begin(57600);
  sd.begin();
  int m = millis(); // just to time everything

  // critical line that prevents delays
  file.open("FILE0000.TXT", O_WRITE | O_TRUNC | O_CREAT); file.close();

  // file we actually want to write to
  file.open("FILE6005.TXT", O_WRITE | O_TRUNC | O_CREAT);
  Serial.println(millis()-m); // print how long it took to open

  file.println(F("test"));
  Serial.println(millis()-m); // print how long it took to write
  file.close();
}
void loop(){
}

When the "critical line" in the code is commented out, I get a big delay in the first write to the file. When it's uncommented, there's no delay, and I never get a delay on that disk again even with the line commented. I saw this on all six disks.

One further bit of mystery: at first, this did not work on one of the cards. I checked and found that this card alone had a hidden ".Trash-1000" directory. I removed that directory and tried again, and this fix did work that time.

Does anyone have any idea what's going on here?


texts:
One of the FastLED examples that I've seen was using code that looks like this:

  EVERY_N_MILLISECONDS( 300 ) { transition_step(); }

I've copied it and successfully used it in the same context - but I have no idea what it is or how it works.

A Google search finds no reference anywhere at all.

I'm still a beginner with C but this looks like a Define to me - all being in uppercase - is it defined somewhere in the FastLED library?


texts: Choose the correct solar panel and battery for solar use

texts:
I am planning to build a weather station powered by solar power. I want to use an Arduino Nano because it's low power requirement. I want to connect some basic sensors to it (temperature, humidity…) as well as an anemometer, a wind vane and a rain gauge. The weather data should be sent wireless via 433 mhz to a raspberry pi, which acts as a web server. I do not have power cable access to the Arduino so solar is the only option.

Which solar panel should I use? I was planning to use 2 2.5W 5.5V panels which charge a Lithium-Ion battery which powers the Arduino using a step up converter. Assuming I have 2-4h of direct sunlight per day and I want to query the sensors every 5 minutes, how big of a battery should i choose? I don't want it to go out of power and want it to last a couple of days without sun.


texts:
I want to automate the chicken coop of my grandmother. To do so, I want to use Arduinos and NodeMCUs, respectively. I want to check if all chickens are in the coop at night and then close a little door. I was trying to use RFID technology and tag the chickens with a little RFID tag but the read range I got was too short to get it working properly. Now, I am trying to implement a light gate with two small lasers and two receivers. I want to detect the direction (in or out) of the chickens. I got the lasers working and I get a signal (1  and 0 = light gate interrupted). I have to know which of the two laser detectors first detected a 0 (zero). I have no idea how to implement this in code. I was trying to use timers to no avail. I also was trying to use interrupts (see small code fragment).

I hope I made clear what I am trying to achieve. Please tell me if and how I can improve this question. Any google fu was to no avail. Every hint/help is greatly appreciated.

#include <Arduino.h>

// Functions
void pin_ISR();

const int detectorPin = 3;     // the number of the detector pin
const int ledPin =  13;      // the number of the LED pin
const int Laser = 6;
// variables will change:
volatile int buttonState = 1;         // variable for reading the status

void setup() {
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(detectorPin, INPUT);
pinMode(Laser, OUTPUT);
digitalWrite(Laser, HIGH);
// Attach an interrupt to the ISR vector
attachInterrupt(digitalPinToInterrupt(3), pin_ISR, CHANGE);
}

void loop() {
Serial.print(buttonState);
delay(100);
}

void pin_ISR() {
Serial.println("There was an interrupt!");
buttonState = digitalRead(detectorPin);
digitalWrite(ledPin, buttonState);
}


texts: Arduino Uno - What can I make with just the base board

texts:
So I just bought my first Arduino (an Uno r3), and dove right in.

All I have currently is the base board (I didn't want to invest too heavily and then realize arduinos weren't for me), so I made a quick script that translates input letters to morse via the LED on the top.

Now that I'm done with that, I figured I'd come here to ask: do you guys have any random ideas for things I can make with JUST the uno? I understand that I should probably just start buying kits and shields, but I'm just curious as to what I can make with the most minimal of items. I consider it a test :)

Thanks in advance guys!


texts: Resistance measurement using loop resistance technique

texts:
Im trying do a circuit to measure resistance between Neutral and ground, for this I tried ohm law method i.e., to obtain R = (V/I). Voltage is known value 25 Vac, Current value is measured using ACS712 and tried the coding is given below, I'm getting current value from it, but when I apply ohms law I'm not getting resistance value.Please guide me

/*
Measuring AC Current Using ACS712
*/
const int sensorIn = A0;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module

double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;

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

void loop(){

 Voltage = getVPP();
 VRMS = (Voltage/2.0) *0.707;
 AmpsRMS = (VRMS * 1000)/mVperAmp;
 Serial.print(AmpsRMS);
 Serial.println(" Amps RMS");

}

float getVPP()
{
  float result;

  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here

   uint32_t start_time = millis();
   while((millis()-start_time) < 1000) //sample for 1 Sec
   {
       readValue = analogRead(sensorIn);
       // see if you have a new maxValue
       if (readValue > maxValue)
       {
           /*record the maximum sensor value*/
           maxValue = readValue;
       }
       if (readValue < minValue)
       {
           /*record the maximum sensor value*/
           minValue = readValue;
       }
   }

   // Subtract min from max
   result = ((maxValue - minValue) * 5.0)/1024.0;

   return result;
 }


texts: WaveShare EPaper Display and Adafruit HUZZAH32 ESP32 Feather Board

texts:
I'm trying to understand how I could use WaveShare EPaper Display with Adafruit HUZZAH32 ESP32 Feather Board.

With these connections

SDI/SCK -> MOSI
SCK/SCLK -> SCK
CS -> 15
DC -> 33
RST/Reset -> 27
Busy -> 32

and this code

#include <GxEPD.h>
#include <GxGDEP015OC1/GxGDEP015OC1.cpp>    // 1.54" b/w
#include <GxIO/GxIO_SPI/GxIO_SPI.cpp>
#include <GxIO/GxIO.cpp>
#include <Fonts/FreeSansBold24pt7b.h>

GxIO_Class io(SPI, 15, 33, 27);
GxEPD_Class display(io, 27, 32);

const char* name = "FreeSansBold24pt7b";
const GFXfont* f = &FreeSansBold24pt7b;

void setup() {
  randomSeed(analogRead(0));
  Serial.begin(9600);
  Serial.println("Starting...");
  display.init(9600);
  //display.setRotation(1);
  display.fillScreen(GxEPD_BLACK);
  display.setFont(f);
  display.update();
  delay(2000);
}

void loop() {
  Serial.println("showing randon number...");
  showRandomNumber();
  delay(2000);
}

void showRandomNumber() {
  String randomString = String(random(1, 60));

  uint16_t box_x = 60;
  uint16_t box_y = 60;
  uint16_t box_w = 90;
  uint16_t box_h = 100;
  uint16_t cursor_y = box_y + 16;

  display.setRotation(45);
  display.setFont(f);
  display.setTextColor(GxEPD_BLACK);

  display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  display.setCursor(box_x, cursor_y+38);
  display.print(randomString);
  display.updateWindow(box_x, box_y, box_w, box_h, true);

}

but I don't get any reaction from the display, do you see something wrong in the code or the connections?

thanks a lot for your help

References

https://github.com/dgarrett/BasicEPaperReader
https://danthegeek.com/2019/02/04/iot-calendar-creating-a-custom-featherwing/
https://github.com/juanpabloaj/esp32_waveshare/blob/master/01_update_window/01_update_window.ino


texts: esp8266 + octocoupler relay: WDT reset when using AC current

texts:
I'm trying to switch on bulb via 4 channel 5V optocoupler relay controller from ESP8266 using WIFI Access point. All my connections looking fine and i can able to connect WIFI SoftAP and send signal to ESP8266 01. Even i can able to switch the Relay from NO to NC or other way around. Only when a connect 240V AC current to relay for powering the bulb, i'm getting following error from ESP

21:11:34.312 ->  ets Jan  8 2013,rst cause:4, boot mode:(1,7)
21:11:34.312 ->
21:11:34.312 -> wdt reset

If i use 12V DC power to light the led via relay its working fine. if again use 240V power to relay to light bulb i'm get same error again.

I have already tried using ceramic capacitor for decoupling to avoid noise from AC. Still no luck. Please advice. I'm very new and naive at handling electronics.

Adding the circuit as well.

Update: After further testing, I can see following behaviour,
If i connect AC bulb to relay and turn it on. Then by provide a long gap before turning it off makes the ESP stable for longer time.

Even better, if i turn off/on my mobile wifi between each time i turn on or off the AC bulb then ESP is always stable.

Adding my code as well.

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

/* Set these to your desired credentials. */
const char *ssid = "*****";
const char *password = "*********";

ESP8266WebServer server(80);

const int led = 2;  //GPIO2

/* Just a little test message.  Go to http://192.168.4.1 in a web browser
 * connected to this access point to see it.
 */
void handleRoot() {

  int size=1000;
  char temp[size];

  int sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;

  snprintf ( temp, size,

"\

Status: Light ON

\

Turn ON

\

\

Turn OFF

\
  \
  ",

    hr, min % 60, sec % 60
  );
  server.send ( 200, "text/html", temp );

}

void setup() {
    delay(1000);
    Serial.begin(115200);
    Serial.println();
    Serial.print("Configuring access point...");

    /* You can remove the password parameter if you want the AP to be open. */
    WiFi.softAP(ssid, password);

    IPAddress myIP = WiFi.softAPIP();
    Serial.print("AP IP address: ");
    Serial.println(myIP);

  pinMode(led, OUTPUT);
  digitalWrite ( led, HIGH );

  //URLs available to query
    server.on("/", handleRoot);
  server.on ( "/on", turnON );
  server.on ( "/off", turnOFF );
    server.begin();
    Serial.println("HTTP server started");

}

void turnON(){

  digitalWrite ( led, HIGH );

  int size=1000;
  char temp[size];

  int sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;

  snprintf ( temp, size,

"

Turn OFF

",

    hr, min % 60, sec % 60
  );

  server.send ( 200, "text/html", temp);

}

void turnOFF(){

  digitalWrite ( led, LOW );

  int size=1000;
  char temp[size];

  int sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;

  snprintf ( temp, size,

"

Turn ON

",

    hr, min % 60, sec % 60
  );

  server.send ( 200, "text/html", temp);

}

void loop() {
    server.handleClient();
}


texts: Reading data from potentiometer with MISO and MOSI on same pin

texts:
I am working with the MCP4131 Digital Potentiometer and I am running into some trouble. The MISO and MOSI functionalities are multiplexed onto the same pin. Obviously, this means that I have to have Pin 13 and 12 hooked into the same pin on the chip.

I want to read send a READ command to the chip so that I can get the current value of the POT; however, when I send the lower byte in order to retrieve the value, I simply am getting back whatever I send because pins 13 and 12 are hooked into the same spot.

Is there any examples on how to work with a module such as the MCP4131 where the MISO and MOSI are on the same pin? Thank you!


texts: What is the physical location of the U1A symbol on Arduino Uno?

texts:
I'm trying to find an easy way to allow an Arduino Uno to determine if it's being powered from USB or the DC barrel jack. In this thread, one user recommends wiring the output of the on-board comparator op-amp (U5A pin 1) into the digital input pin.

I couldn't find U5A on the current schematic, but I think he's actually referring to U1A pin 1. Is this correct?

Unfortunately, I'm not sure where on the physical Arduino that device is located. I have one in front of me, and almost none of the parts are labeled on the silk screen. How do I find out where it is? I've googled for Arduino Uno part placement schematics, but all I'm finding are blurry unlabeled low-res images.


texts:
Would it be possible to detect when somebody closes/opens/uses their keyfob (based on radio frequency) ? It is of course not the intention to hack the key. Just knowing when somebody has pushed a button on it.

If so what could be the possible range and what hardware/software should be needed (what antenna?, Arduino, Raspberry pi, extra software or drivers etc...)

Thank you so much for your help.


texts: This error is shown continuosly after first time it compiles successfully

texts:
I got this error:

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

Multiple libraries were found for "LiquidCrystal.h"  Used: C:\Program
Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.10.0_x86__mdqgnx93n4wtt\libraries\LiquidCrystal
Not used:
C:\Users\siddh\OneDrive\Documents\Arduino\libraries\libraries readlink
C:\Users\siddh\OneDrive\Documents\Arduino\libraries\SimpleDHT\SimpleDHT.cpp:
The system cannot find the file specified. Error compiling for board
Arduino/Genuino Uno.

This report would have more information with "Show verbose output
during compilation" option enabled in File -> Preferences.

This is the code i use:

//We'll start by adding our libraries

 #include <LiquidCrystal.h>

 #include <SimpleDHT.h>

//Declaring digital pin no 6 as the dht11 data pin

int pinDHT11 = 6;
SimpleDHT11 dht11;

//Declaring the lcd pins

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
// Don't forget to choose 9600 at the port screen

  Serial.begin(9600);

//Telling our lcd to start up

  lcd.begin(16, 2);

}

void loop() {

  //These serial codes are for getting readings on the port screen aswell as the LCD display, since they'll offer us a more detailed interface

  Serial.println("=================================");
  Serial.println("DHT11 readings...");
  delay(2000);

  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;

  //This bit will tell our Arduino what to do if there is some sort of an error at getting readings from our sensor
  if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("No reading , err="); Serial.println(err);delay(1000);
    return;
  }

  Serial.print("temp: ");
  Serial.print((int)temperature); Serial.print(" Celcius, ");
  Serial.print("humidity:");
  Serial.print((int)humidity); Serial.println(" %");

  //Telling our lcd to refresh itself every 0.75 seconds
  lcd.clear();

 //Choosing the first line and row

 lcd.setCursor(0,0);

//Typing Temp: to the first line starting from the first row
  lcd.print("Temp: ");

//Typing the temperature readings after "Temp: "
  lcd.print((int)temperature);

//Choosing the second line and first row
  lcd.setCursor(0,1);

//Typing Humidity(%): to the second line starting from the first row
  lcd.print("Humidity(%): ");

//Typing the humidity readings after "Humidity(%): "
  lcd.print((int)humidity);

  delay(750);
}


texts: Arduino analog input to iphone notification

texts:
I need some help :)

Is it even doable?
Is there anyone who wants to help me program it?

My wish:
I want to receive a iphone notification when 1 arduino analog input drop from 5 to 0 volt.
Then (later) when the voltage goes back to 5V i want another message.
It needs to be over Wifi (not BT).
Is there anyone that can help me with this?
Thanks in advance


texts: Error while installing bootloader ATmega328

texts:
I'm trying to install a bootloader on my ATmega328P-PU. I'm trying to install it from Arduino Uno (not original). I can install all sketches. After I click "Burn bootloader" I get the following error:

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

avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATmega328P is 1E 95 0F
 ***failed;
avrdude: verification error, first mismatch at byte 0x0000
         0x00 != 0x3f
avrdude: verification error; content mismatch
Error while burning bootloader.

How to fix it?


texts: Hello I have been here for a couple hours troubleshooting code and turns out it wasn't even my code that was the problem. My arduino uno is like 2 times slower than what its supposed to be. If I blink a led with a delay of 500ms it takes 1 second. I was using it last night and it was working just fine. I am working on a remote of sorts and the IR led was going retartedly slow. So then I switched it to my backup, still didn't work. Then digitalWrite showed me it was 2 times slower than it should be. I haven't done anything to it besides the following: (Flashed it around 100 times since i got it). I've only had it for like a month so I would appreciate if someone could tell me what I could do to fix it :/


texts:
I've a joystick and a servo connected to my UNO, but for some reason my calculations keep on being wrong? I'm trying to calculate how the rotation should be of my servo (Tower Pro 9g, max value of 180 I think) with my Joystick (Keyes_SJoys, max value of 1023 on any axis) and example would be:

y = 500;
servo.write(y * 180 / 1023); // should equal to 87.97, but in reality it's 24?

#include <Servo.h>

Servo servo;
int d2 = 2;
int a0 = 0;

void setup() {
  Serial.begin(9600);
  servo.attach(d2);
}

void loop() {
  int y = analogRead(a0);
  Serial.print("y: "); Serial.println(y);

  servo.write(y * 180 / 1023);
  Serial.println(y * 180 / 1023);

  delay(100);
}

PS. It's a Robotale UNO; I don't know if that makes any difference or not, but.


texts: How to wire QRB1114 IR sensor to an Arduino Uno

texts:
What's the best way to wire a QRB1114 IR sensor to an Arduino Uno? I'm attempting to use it as a white-line-on-black-background line detector. Google shows many different ways wire it to an Arduino, but I'm using this one because of its simplicity.

However, when I tested the circuit using the AnalogInput example code, I'm not getting the expected behavior. It registers a reading of 0 for both white and black backgrounds (I'm using white and black electrical tape as test surfaces), and occasionally registers between 5-10 if there's nothing in front of it at all.

What is the most likely problem? Is this circuit an improper way of wiring the sensor? Is my sensor defective? Is the code not reading it properly?

This is my test code:

#define BUTTON_PIN 2
#define LED_PIN 13

const int IR_SENSOR_PIN = A0;
int sensorValue = 0;

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

void loop() {
    sensorValue = analogRead(IR_SENSOR_PIN);
    Serial.println(sensorValue);
    delay(1000);
}


texts: Erasing 1 byte of external Flash memory (winbond)

texts:
i'm trying to use an external flash memory Winbond 25q64jvsiq for my Arduino Nano based project for audio recording purposes, to have extra memory for recording 1 byte audio samples, since Arduino nano SRAM memory is too small (8kb), to store at least 1 second of 8 kHz 8 bit samples audio. I'm trying to understand the basics of  bytes storing in my external memory. I'm using SPIMemory library for that, and i can't find a function to erase 1 byte, there is only sectorErase() function. So i wonder is it even possible to erase a single byte of external memory?
Here is a part of code where i try to rewrite (erase one byte and write a new one) a next byte when the button pressed, but when it erase a sector it erases not the one byte but all bytes behind it, and i want to manipulate it more accurate, and erase only one byte:
if(!digitalRead(5)){      //button pressed
     if(e<3){
      e++;
      flash.eraseSector(count);    //erasing a byte
      flash.writeByte(count,e,NOERRCHK); // write a new value
      }  else {
        e=0;
        flash.eraseSector(count);
        flash.writeByte(count,e,NOERRCHK);
        }
     }


texts: Arduino Uno ADC behavior in free running mode

texts:
I'm using my ATmega328P to sample an analog signal in free running mode. The ADC clock frequency is set to ÷128. I've read that a single analog conversion lasts 13 clock cycles. I would like to know if the number of clock cycles changes if I make the ADC trigger an interrupt after every conversion (ADIE bit set to one). Or will the ADC still use 13 clock cycles and start again on the 14th?

If ADIE is set to zero (no interrupts) will the result of the conversion still be written to ADCL and ADCH? And at what time of the 13 clock cycles is this result written to those registers? This is important to me so I can calculate how much time I have to read those registers.

Would it be possible to set ADIE to zero and instead use a timer interrupt to read ADCL and ADCH every ~1 millisecond. Or am I missing something important?