texts: arduino & drivers to control 5 brushed CIM motors independently?

texts:
i am a complete newbie in electronics but i'm a bit familiar with C.
i am building a machine that requires 5 little engines (12V 2.5in brushed CIM motors) & motor drivers (i need to adjust each motor's speed).
i've got an arduino UNO which i think is too small to control that many motors.
i would like to know if the setup i want was feasible to your opinion and which ardunio would i need to do that ?
i guess an Arduino Mega ?

also, i came accross this tutorial : https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-control-tutorial-l298n-pwm-h-bridge/
it explains how to configure an arduino with a driver & two motors.

in fact i want to prepare the same kind of thing but with 5 motors that i can control independently.

which hardware would you recommend to do such a thing please ?

many thanks !
regards


texts: ATMega328P U Query - does it work straight away on Uno R3

texts:
Quick query (I hope).
I have an Arduio R3 board with ATMega328P U on board. It works fine. I bought some new MCUs, ordered with bootloader. Same IC designation. Before I dive into my new project I want to confirm they are okay.
So ...............I take the original MCU out of the Arduino R3 and replace it with a new ATMega328P U. Should it work fine straight away? i.e. can I upload simple sketches like Blink?
My problem is that I've done this and none of them work. I get two flashes on the Rx LED on the board, then ArvDude gives me a string of "not in sync" error messages. If I put the original MCU back in then everything works okay again. I don't want to go through the hassle of burning bootloader on chips that supposedly have it, I'd rather send them back.
Are my new MCUs duff? Or is there any other easy way to check them?
Many thanks


texts: ESP32 not seen by a network analyzer application in server mode

texts:
I have used the scan wifi and blink examples provided by Espressif,
they are both working on the ESP32 using arduino ide.

However, I can not see my ESP( the SSID and signal strength) in the list of detected wifi when searching for it using a network analyzer app  ( Net analyzer on android)

This was solved when I used the ESP as Access point.
In Client mode the ESP is using the WIFI capability. But why it can not be seen by others?

why is the ESP32 Lolin getting hot only when it is in AP mode?

Thanks in advance


texts:
First of all, i have some problems with an lcd .
For a better understanding, the lcd datasheet could be found here:
https://www.mikrocontroller.net/attachment/53098/DGF-12232-S1FBLY-325-17231-1006.pdf

i want to connect it to arduino mega but it has 20 pins and i can't figure it out how it should be connected.
Could someone help me ?


texts: Can I power my shift register with a 12V external power supply and connect only the data, strobe and clear pins to the Arduino digital pins?

texts:
I'm using a CD4094 shift register to power my LEDs along with a ULN2003A darlington transistor array. I want to hook up the LEDs to an external power supply of 12V (common anode).

The cathodes of little groups of LEDs will be connected to the ULN2003A which is connected to the shift register which will get its data from the arduino (the digital pins which i assume work at 5V).

My question is, if I connect the Vdd pin of the shift register to the 12V external power supply, will it still function as intended through the Arduino?


texts:
In the example of the arduino starter kit the point is to use a potenciometer to control a servo.

The code is

angle = map(potVal, 0, 1023, 0, 179);

The output in the serial

potVal: 1023, angle: 179
potVal: 1015, angle: 177
potVal: 1023, angle: 179
potVal: 1016, angle: 177
potVal: 1023, angle: 179
potVal: 1023, angle: 179

I noticed that the servo is shaking like trying to go passing over the 179, when it is suppose to use an angle max 180º (0-179)

What could be the problem?


texts: Compiling SRAM intensive code from Raspberry Pi 3

texts:
I am using an Arduino Uno R3 to control my Christmas lights (a strand of 665 WS2812B LEDs).

I am using the Pololu library that can be found here:
https://github.com/pololu/pololu-led-strip-arduino
This library has been the most memory efficient one of its kind that I have found. It is the only one with which I could run my entire strand. I have been able to run it with up to 670 LEDs when compiling the code from my Windows PC.

The Arduino, while driving the LEDs, is not accessible from my PC, so I am attempting to use a Raspberry Pi with VNC installed to control it remotely, and update the Arduino code on demand. However, when compiling the exact same code (the LedStripXmas example from the Pololu library) on the Raspberry Pi, I am only able to get 650 LEDs working. If I try upload a code with more than that, the program will not run. The Raspberry Pi Arduino software also does not show the message:
"Global variables use 2,012 bytes (98%) of dynamic memory, leaving 36 bytes for local variables. Maximum is 2,048 bytes."

Is there a way to display this information from the Raspberry Pi?
Is there a difference in the PC and Raspberry Pi compilers?

Edit:
I uninstalled the IDE from the standard repository and installed the ARM version from the website. Now with the exact same code as from my PC, I am getting a ton of Narrowing warnings and the code does not run with any number of LEDs.


texts: Timer question: Phase Correct PWM at specific frequency

texts:
I am trying to create a sinusoidal wave segmented in 64 Frame, each holding a Duty cycle precisely varying from 0x00 to 0xff. This is for an Arduino Nano.
I have trouble understanding the following:

Which Wave Generator Mode and Matches will cause an interrupt at the constant Frame as well as help do a phase correct/fast PWM for the varying Duty Cycle?
How to tell which pin to use? I guess OC0B means Pin5 according to Pin Mapping but I'm not sure I truly understand.

This is what I have for the moment.
const byte waveFrame = 126;
const byte wave[]    = {
    0x80,0x98,/*a total of 64 values*/,0x67
};
byte frame = 0;
void setup(){
    pinMode(3,OUTPUT);
    noInterrupts();
    TCCR0A = (1<< WGM00)  // Phase correct PWM with top as OCR0A
           | (1<<COM0A0)  // Toggle OC0A on match
           | (1<<COM0B1); // Clear/Set OC0B on Compare Match when up/down-counting.
    TCCR0B = (1<<  CS01); // Prescaler of 8 (16MHz/8= 2MHz)
    TCNT0  = 0;           // Counter restarted
    OCR0A  = waveFrame;   // Constant frequency/64 for each frame
    OCR0B  = 0;           // Duty Cycle
    interrupts();
}
ISR(TIMER2_COMPA_vect){
    OCR0B = wave[frame & 0x3f]; //Rolls around
    frame++;
}

Thank you! I've lost a little bit of hair on this.


texts:
I make simple code to read web page by ITEAD Gboard. Here is my code:

  Serial.write("\nStarting..........\n");
  mySerial.print("AT+CSQ");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----1-----\n");

  mySerial.println("AT+CGATT=1");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----2-----\n");

  mySerial.println("AT+CGATT?");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----3-----\n");

  mySerial.print("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----4-----\n");

  mySerial.print("AT+SAPBR=3,1,\"APN\",\"internet\"");
  delay(2000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----5-----\n");

  mySerial.print("AT+SAPBR=1,1");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----6-----\n");

  mySerial.print("AT+HTTPINIT");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----7-----\n");

  mySerial.print("AT+HTTPPARA=\"URL\",\"xx.xx.xx.xx/my/web/site\"");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----8-----\n");

  mySerial.print("AT+HTTPDATA=100,1000");
  delay(10000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\n-----9-----\n");

  mySerial.println("AT+HTTPREAD");
  delay(1000);

  while(mySerial.available()!=0)
    Serial.write(mySerial.read());

  Serial.write("\nend.\n");

Which i get the following output:

Starting..........
AT+CSQ
-----1-----
AT+CGATT=1

ERROR

-----2-----
AT+CGATT?

+CGATT: 1

OK

-----3-----
AT+SAPBR=3,1,"CONTYPE","GPRS"
-----4-----
AT+SAPBR=3,1,"APN","internet"
-----5-----
AT+SAPBR=1,1
-----6-----
AT+HTTPINIT
-----7-----
AT+HTTPPARA="URL","xx.xx.xx.xx/my/web/site"
-----8-----
AT+HTTPDATA=100,1000
-----9-----
AT+HTTPREAD

ERROR

end.

AT+HTTPREAD return error. What wrong with me?

Note

xx.xx.xx.xx/my/web/site is my web page. The error is still there for all web page.


texts: What are exactly XTAL1 and XTAL2 pins in Arduino Uno/Nano?

texts:
I know that the blow red encircled component is the 16MHz Crystal Oscillator (XTAL):

But PB6 and PB7 pins are called XTAL1 and XTAL2 pins which are not accessible by the Arduino board.

Are these pins where the 16MHz crystal oscillator is connected. But if so why are they two of them? I searched net but couldn't find explicit information about these.

How many clocks in total this board have?


texts: Every time I try to upload code to my arduino I always get this error : avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x17. How do i fix it ?


texts:
Is it possible to kill arduino nano with overload?
I wanted to drive a relay with arduino, and I used a BC547 to switch 12V for the relay.
But in the relay there was a diode, which sorted out the circuit (thats why I drawed in the wrong orientation)
I know it was a mistake to not use current limiting resistor on Base of the transistor.
Is it possible that this shorted circuit made too much current on the transistor base which killed my arduino?
I made this circuit:


texts:
This is my first script written with Arduino. I wrote a simple Hello World program but I'm getting the following error.

Test:18: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
   Keyboard.begin();
   ^
exit status 1
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

Here is the code:

#include "Keyboard.h"

void typeKey(int key)
{
  Keyboard.press(key);
  delay(50);
  Keyboard.release(key);
}

void setup()
{
  // Begining the Keyboard stream
  Keyboard.begin();

  // Wait 500ms
  delay(500);

  delay(400);

  Keyboard.print("Hello World!");

  // Ending stream
  Keyboard.end();
}

void loop() {}

I have Arduino/Genuino UNO selected as my board on the IDE. Any suggestions on how I can fix this? Thanks


texts: The USB Serial speed on the teensy is WAY faster then on the Leonardo. Looks like because they have greatly improved the USB code. Has anyone had any luck using the Teensy core libraries on a Leonardo? I would imagine it should work as the hardware is basically the same.


texts: Sublime Text 2 with stino, compilation gives "filename ... is incorrect" Arduino IDE 1.7.8

texts:
I can't compile a simple blink sketch.

Error is:

[Stino - Start building "t5"...]
[  3%] Creating C:\Users\lov\AppData\Local\Temp\Stino_build\t5\t5.ino.cpp.o...
The filename, directory name, or volume label syntax is incorrect.

See also see similar question, that answer not working here.

Path to IDE app is C:\Program Files (x86)\added\Arduino.


texts: I have an SPI flash based mp3 module and was wondering whether its possible to write to the flash chip using a microcontroller(arduino). the IC supports FAT16/FAT32 file systems. I have researched arduino and the fat file system but they are all in relation to SD cards which operate differently as far as i understand. Is it possible to write data to a fat file system on SPI flash using an arduino?


texts:
I am working on a project with an Arduino Nano that includes a keypad, screen, and the NRF4001 transceiver. The keypad requires 7 digital pins to operate, the wireless transceiver uses pins D9 - D13 with the RF24 library I am using. Now, that leaves me with 1 Digital Pin left for a screen unless there is an I2C screen I could use.

That would be easy enough to find except that I have some limitations. If at all possible I would like the screen to be under 5 dollars and about the size of a Nokia 5110. The Nokia uses to many pins and does not tolerate 5v logic levels I've heard. An OLED 0.96 inch is only a 4 bucks and is I2C, but it is too small. I could make a board for the keypad that used different values of resistors and one analog pin to detect different buttons but would rather not go that route if there is any easier way to get around this.

Are there any options out there that would suffice my pin, cost and size conditions or am I being too picky?


texts:
I'm new to Arduino and am working on a project with my son.  We are using the LillyPad USB board (schematic) to drive a bunch of LEDs (LED Datasheet).  Our project is based loosely off of the 'Turn Signal Biking Jacket'.

Our project calls for 7-11 LEDs in parallel on a single circuit.  In the 'Turn Signal' project the LEDs are driven off of a pair of output pins (1 HIGH and 1 LOW).  In a circuit that looks like this...

simulate this circuit – Schematic created using CircuitLab

Is this ideal?  Would it make more sense to connect the LED-chain to Vcc and have the return line connected to a single output set to LOW (to turn on the lights)?

If we were to have 3-4 of these LED-chains on at once, do I have to be concerned with total draw on the microcontroller?

Help? Thoughts?


texts: Communication between IC and microcontroller (Teensy 3.2)

texts:
I am trying to use a rotary encoder with an integrated circuit to measure the position of a rotating shaft. I am then taking this data and writing to an SD card. The IC seems to be working correctly and outputting binary data to the specified pins,  but the data does not seem to be reaching the micro-controller. My output data is fragmented, and seems to only be receiving binary data from some of the IC pins. The IC I am using is HCTL-2021-A00 (http://www.mouser.com/ProductDetail/Avago-Technologies/HCTL-2021-A00/?qs=RuhU64sK2%252bsgeK17XZB%2fNA%3d%3d). I tried using a larger gauge wire to connect the two, but then the micro-controller didn't seem to pick up any of the data. Here is the code I used.

I am trying to use a rotary encoder with the HCTL-2021-A00 from avago. I am getting data output from the IC, but only one of the two bytes which it should be providing. When I move the encoder forward, it will only give me the LOW byte and all of the high bits will be zero. However, when I move the encoder backward, all of the high data bits are 1, and the low data bits still operate normally, counting the position. What could cause the high data bits to all be 1 when moving backward, and all 0 when moving forward? Code used is below.

#include <SD.h>
#include<SPI.h>

File datafile;
const int chipSelect = 10; // connected to the CS pin on the sd card, Make sure the card is formatted
int encoderpos=0;
int i=0;
int pulses, A_SIG=0, B_SIG=1;
int b[15];  //the individual bits of data read from the IC
int pos; //position output of IC ranging from 0 to 5000 for 1 revolution
int selpin=1, OEpin=2;
int clock=4;
int d[7]; //the pins on the IC attached to which digital teensy pins
double deg; //degree position of the servo as found from the encoder and IC

void setup()
{
  //set pwm signal for timer input
  pinMode(4, OUTPUT);
  analogWriteFrequency(4, 6000000); // Teensy 3.0 pin 3 also changes to 375 kHz
analogWrite(4, 128);
   //First setup and attach the pins used to communicate with the IC and encoder
  d[0]=22;//pin numbers for attaching the IC to the teensy
  d[1]=21;
  d[2]=20;
  d[3]=19;
  d[4]=18;
  d[5]=17;
  d[6]=16;
  d[7]=15;
//first set pins as inputs and outputs
pinMode(selpin, OUTPUT);
pinMode(OEpin, OUTPUT);
pinMode(d[0], INPUT);
pinMode(d[1], INPUT);
pinMode(d[2], INPUT);
pinMode(d[3], INPUT);
pinMode(d[4], INPUT);
pinMode(d[5], INPUT);
pinMode(d[6], INPUT);
pinMode(d[7], INPUT);

digitalWrite(selpin, HIGH);
digitalWrite(OEpin, HIGH);

pinMode(5, OUTPUT);

digitalWrite(5, HIGH);
delay(5);
digitalWrite(5, LOW);
delay(5);
digitalWrite(5, HIGH);
delay(5);

pinMode(chipSelect, OUTPUT);
SD.begin();
datafile=SD.open("c.txt", FILE_WRITE);
pinMode(7, INPUT);
pinMode(8, OUTPUT);

}

void loop()
{
datafile.println(pose());
if (millis()>4000)
{
  datafile.close();
}

delay(5);
}

int pose()     //Gives the position in degrees from the readings from encoder and IC for 0 to 5000 representing one revolution
{
    digitalWrite(selpin, LOW);     // The sel pin on the IC
  digitalWrite(OEpin, LOW);     // The OE pin on the IC
digitalWrite(4, HIGH);
digitalWrite(4, LOW);
analogWrite(4, 128);

  b[0]=digitalRead(d[0]);
  b[1]=digitalRead(d[1]);
  b[2]=digitalRead(d[2]);
  b[4]=digitalRead(d[4]);
  b[5]=digitalRead(d[5]);
  b[6]=digitalRead(d[6]);
  b[7]=digitalRead(d[7]);
if(digitalRead(7)==1)
{
  digitalWrite(8, HIGH);
}
else if(digitalRead(7)==0)
{
  digitalWrite(8, LOW);
}
  digitalWrite(selpin, HIGH);
digitalWrite(4, HIGH);
digitalWrite(4, LOW);
analogWrite(4, 128);

  b[8]=digitalRead(d[0]);
  b[9]=digitalRead(d[1]);
  b[10]=digitalRead(d[2]);
  b[11]=digitalRead(d[3]);
  b[12]=digitalRead(d[4]);
  b[13]=digitalRead(d[5]);
  b[14]=digitalRead(d[6]);
  b[15]=digitalRead(d[7]);

  digitalWrite(OEpin, HIGH);

  pos=0;
  i=8;
  for(i; i>0; i--)
  {
pos=2*pos+b[i-1];
  }

  i=16;
  for (i; i>8; i--)
  {
    pos=2*pos+b[i-1];
  }

  return pos;

}


texts:
I'm currently attempting to use an Arduino Micro as a ducky USB for penetration testing, and currently when I attempt to open a command prompt (or any other window) the window loses focus which prevents me from typing anything in it. Here's my sample code:

#include <Keyboard.h>

void setup() {
  delay(5000); //Delay for testing
  Keyboard.begin();

  Keyboard.write(KEY_LEFT_GUI);
  delay(400);
  print(F("notepad"));
  enter();

  Keyboard.print("This is a test");
  enter();

  clear();
  Keyboard.end();
}

void print(const __FlashStringHelper *value) {
  Keyboard.print(value);
}

void clear() {
  Keyboard.releaseAll();
}

void enter() {
  Keyboard.write(KEY_RETURN);
  Keyboard.releaseAll();
}
void loop(){}

Any thoughts on what might be causing this? I'm testing it on windows 10 home (not sure if that matters).


texts: Why doesn't millis() use 1 µsec or 1 msec interrupt?

texts:
Arduino millis() does not make use of one millisecond interrupt. Instead they make use of 1,024 µsec interrupts and manipulate. Any specific reason why this was implemented this way?

In one case, we can go for timer0 without prescaler and use 1 µsec interrupts. In such case, we have to use CTC mode with OCR0A=15. Inside ISR, we could update the microsecond counter and if it reaches 1,000, we could update the msec timer count. Otherwise we could go for directly 1 msec interrupt (maybe using timer0).

I wrote this code to get micros() and millis(). But there is some issue and I'm not able to get it working correctly.

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

#ifndef F_CPU
#define F_CPU 16000000UL
#endif

volatile uint32_t oneMilliCounter;
volatile uint32_t oneMicroCounter;
extern void initializeTimer0CTC_Mode (void);

extern uint32_t millis(void);
extern uint32_t micros(void);

volatile uint32_t oneMilliCounter = 0;
volatile uint32_t oneMicroCounter = 0;

uint32_t millis(void) {
  uint32_t value;
  uint8_t sregCopy = SREG;
  cli();
  value = oneMilliCounter;
  SREG = sregCopy;
  sei();
  return (value);
}

uint32_t micros (void) {
  uint32_t value;
  uint8_t sregCopy = SREG;
  cli();
  value = oneMicroCounter;
  SREG = sregCopy;
  sei();
  return (value);
}

void initializeTimer0CTC_Mode (void) {
  OCR0A = 15; // Set for 1 usec.
  TCCR0A |= 1 << WGM01;  // CTC Mode
  TIMSK0 |= 1 << OCIE0A;
  TCCR0B |= (1 << CS00); // prescaler=1
}

ISR(TIMER0_COMPA_vect) {
  static uint32_t prevMicro;
  oneMicroCounter++;
  if (oneMicroCounter - prevMicro >= 1000)   {
    prevMicro = oneMicroCounter;
    oneMilliCounter++;
  }
}

int main(void) {
  DDRD |= 1 << PD3;
  initializeTimer0CTC_Mode();
  sei();
  uint32_t prevTime = micros();
  while (1) {
    uint32_t currentTime = micros();
    if (currentTime - prevTime >= 1000) {
      PORTD ^= (1 << PD3);
      prevTime = currentTime;
    }
  }
  return (0);
}


texts: 16x2LCD Display serial read extra character

texts:
I get extra character (frowning face) when sending a text over the serial monitor(see attached image)

When empty string is sent over the serial monitor, the LCD display still shows the extra character of frowning face.
How do I get rid of the extra character?
I use the tutorial code below and change nothing in the code.
https://www.arduino.cc/en/Tutorial/LibraryExamples/LiquidCrystalSerialDisplay/
#include <LiquidCrystal.h>

    // initialize the library by associating any needed LCD interface pin
    // with the arduino pin number it is connected to
    const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
    LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

    void setup() {
      // set up the LCD's number of columns and rows:
      lcd.begin(16, 2);
      // initialize the serial communications:
      Serial.begin(9600);
    }

    void loop() {
      // when characters arrive over the serial port...
      if (Serial.available()) {
        // wait a bit for the entire message to arrive
        delay(100);
        // clear the screen
        lcd.clear();
        // read all the available characters
        while (Serial.available() > 0) {
          // display each character to the LCD
          lcd.write(Serial.read());
        }
      }
    }


texts: Help with a rather specific implementation of FFT Library?

texts:
So, I guess what I'm trying to do here is properly understand the FFT library posted here by Open Music Labs, done in C++. I believe I understand the Fourier transform, but the FFT has some nuance that I'm not quite familiar with. From what I understand, the FFT takes a amplitude vs. time signal and transforms it into its constituent frequencies like a normal Fourier transform, but it only does so at given points that break down the signal into the Arduino's clock speed divided by the number of bins decided on, for the sake of efficiency. Thus each bin actually accounts for a number of frequencies that is also equal to the clock speed divided by bin number. I'm correct so far, right?

So here's my question. I have a very specific application of the FFT that requires reading only frequencies at roughly 0-100 Hz. Everything else I don't need, and I want to know how to achieve such high resolution. I imagine that because the number of bins seems to be capped at around 512, that there must be some sort of way to decrease the clock speed to an exorbitantly low number in order to read these frequencies. How might I go about doing that? Or maybe there is a better way to apply the transform to the data at such low frequencies through some other method outside of FFT?

Second, I'm wondering how performing multiple FFTs simultaneously will affect performance, and if there is some way I can export this data to another program in order to do the heavy lifting regarding data storage, seeing as I imagine performing many FFTs all at once will decimate the available memory on the Arduino itself if all of those values aren't being kept on my computer.

Thanks in advance for any insight you guys might be able to provide


texts:
I am doing a project which monitors vibrations using an ADXL355 sensor and an Arduino. I have used the MPU-9250 sensor before.
I am not able to find a library or tutorials for calibrating, filtering, and reading accurate data from the sensor. Can anyone who has worked previously with the sensor help me? I am mechanical engineer new to the field of electronics.
If library files are not available, how can I use the datasheet to write the entire code myself? Is there any tutorial available for this?
Sorry if the post seems confusing..


texts: USB mouse/keyboard passthrough feasible?

texts:
I'm looking to achieve the following:

USB HID Mouse (or Keyboard) -> [ Arduino device ] -> PC
                                       |
                                        `-> Internet

Basically, I want to connect a keyboard or mouse to an Arduino device, do some processing, send some data over the internet and then pass-through the USB data to the PC as if the Arduino wasn't even there.

My question is twofold: what hardware should I use? Right now I'm looking at the following peripherals:

Arduino Uno R3 SMD
Arduino Ethernet Shield
SparkFun USB Host Shield

Since I'm a complete neophyte when it comes to Arduino, I wanted to double-check and make sure my parts will fit together as well as work towards my goal. I was also contemplating the Arduino Leonardo (since it seems to provide mouse/keyboard out-of-the-box without reflashing the firmware), but I'm not sure I understand what that decision might entail.

Which brings me to my second question: is this feasible software-wise? I found this blog which has some information about pass-through connections, but the mouse library seems to be unfinished. I'd hate to invest 150+ dollars into a project that is doomed from the start.

Thank you!


texts: Arduino doesnt seem to be reading my pin states

texts:
I seem to have an unbelievable thing. My code was working perfectly on one arduino, when i upload the same sketch to another one, it is behaving strangely, it seems like it is not reading any of my pin states:

The code is ment to drive a simple stepper motor with driver. depending on the state of several pins in which direction it moves or moves at all.

What is happening now is when i upload the sketch the motor starts to turn, nomatter what pinstate any of the input pins have, the motor just turns on uploading and even if i apply 5v to any of the pins, it just keeps turning the same direction.

Following the code. I hope someone could tell me what i am doing wrong, i am a newbie to programming:

int PUL=7; //define Pulse pin
int DIR=8; //define Direction pin
//int ENA=5; //define Enable Pin
int up = 2;
int down = 3;
int limitpin=1;
int limitpinup=4;
int i=0;

int buttonupstate = 0;
int buttondownstate = 0;
int limitstate=0;
int limitstateup=0;

void setup() {
  pinMode(PUL, OUTPUT);
  pinMode(DIR, OUTPUT);
  pinMode(up, INPUT);
  pinMode(down, INPUT);
  pinMode(limitpin, INPUT);
  pinMode(limitpinup, INPUT);
}

void loop() {
  buttonupstate = digitalRead(up);
  buttondownstate = digitalRead(down);
  limitstate = digitalRead(limitpin);
  limitstateup = digitalRead(limitpinup);
  i = 0;
  switch (limitstateup){
  case LOW:
    switch (limitstate){
    case LOW:
      if (buttondownstate==HIGH){
        do
        {
          digitalWrite(DIR,LOW);
          // digitalWrite(ENA,HIGH);
          digitalWrite(PUL,HIGH);
          delayMicroseconds(20);
          digitalWrite(PUL,LOW);
          delayMicroseconds(20);

          buttondownstate = 0;
          buttondownstate = digitalRead(down);
          limitstate == 0;
          limitstate = digitalRead(limitpin);
          limitstateup == 0;
          limitstateup = digitalRead(limitpinup);
        } while (buttondownstate == HIGH && limitstate == 0 && limitstateup == 0);
      }
      if (buttonupstate == HIGH){
        do
        {
          digitalWrite(DIR,HIGH);
          // digitalWrite(ENA,HIGH);
          digitalWrite(PUL,HIGH);
          delayMicroseconds(20);
          digitalWrite(PUL,LOW);
          delayMicroseconds(20);

          buttonupstate = 0;
          buttonupstate = digitalRead(up);
          limitstate == 0;
          limitstate = digitalRead(limitpin);
          limitstateup == 0;
          limitstateup = digitalRead(limitpinup);
        } while (buttonupstate == HIGH && limitstate == 0 && limitstateup == 0);
      }
      break;
    case HIGH:
      do{
        digitalWrite(DIR,HIGH);
        digitalWrite(PUL,HIGH);
        delayMicroseconds(20);
        digitalWrite(PUL,LOW);
        delayMicroseconds(20);
        limitstate = 0;
        limitstate = digitalRead(limitpin);
      }while (limitstate == HIGH );
      break;
    }
    break;
  case HIGH:
    do{
      digitalWrite(DIR,LOW);
      digitalWrite(PUL,HIGH);
      delayMicroseconds(20);
      digitalWrite(PUL,LOW);
      delayMicroseconds(20);
      limitstateup = 0;
      limitstateup = digitalRead(limitpinup);
    }while (limitstateup == HIGH );
    break;
  }
}


texts:
Nano 33 IOT is not detecting by windows . When i plug the usb cable only green light on the board.
Board is installed from the board manager. the cable is usb DATA cable and not charging cable. I tried the double press on the reset button but nothing happen. The L light is Off and the green light isnt flashing.
I plugged the board into another usb port, the same issue. I tried the board on my friend computer also but no luck. I dont have ATmel ICE or any other debugger like j-link.
https://www.youtube.com/watch?v=C0tXa0uxv5c

I hope someone can explain what is the issue, is it hardware or software.


texts: Microcontrollers with built in HID support

texts: I am trying to build a wireless gamepad for which i am using NRF24l01 module for my wireless need and for Sending data to computer i need an mcu which support to act as hid device. So far, i got Attiny85 and mcu with atmega324u. But the problem is that attiny85 has very few pins and i cannot use it as for both hid and nrf module simutaneously due to pins defficiency. And atmega324u mcu are not avialable in my country. Can anybody suggest me some mcu with built in hid support.


texts: How to create TCP server on Arduino UNO WiFi?

texts:
I'm currently trying to make my Arduino UNO WiFi work as a TCP host, so I can send him a TCP message and it sends a response.

I had no problem doing this on the Arduino Galileo Gen 2 using the EthernetServer, but since this one is using WiFi, EthernetServer isn't an option.

I can, however, run a web server, but that's not what I want.

So how do I make the Arduino receive, handle and respond to sent TCP/IP messages?


texts:
I installed Octave support package for Arduino and it is listed in the packages installed when pkg list command is run.But when the command  "a= arduino('COM8')";
is run,"error: serial: Error opening the interface: No such file or directory" is shown.Please respond.


texts:
I am newer to microcontrollers and have my first project I would like to try. I have started to sketch out a basic design and would like feedback on things that I may be missed or over looked. I understand I am new and things are probably not correct or I might miss use terminology, please feel free to correct me in any aspect.
Project Scope- I would like to integrate the MKR Wifi 1010 into Alexa using IoT to have an Alexa command sent to the MKR Wifi 1010 that then pulls in a relay that actuates a 12v solenoid.
Hardware
Power supply 1- FQCMOGU AL-1250, Input 100-240v 1.6a, Output 12v 5a
Power supply 2- Drok 15w DC/DC, Output 5v 3a
Microcontroller- Arduino MKR Wifi 1010
Relay- Songle SRD-05VDC-SL-C
Solenoid Valve- Beduan 12v
Here is a sketch of my original plan. Let me know any safeties/ protections I may have missed, calculations that do not make sense or if there is an easier/ better way. I have not order the hardware yet and want some people better at this than me to check it over before I do.


texts:
I am using Jeff Rowberg's MPU6050 library, and I simply don't understand what is going on in the following lines of the first example (MPU6050_raw.ino):

#include "I2Cdev.h"
#include "MPU6050.h"

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE
// implementation is used in I2Cdev.h
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
    #include <Wire.h>
#endif

So, what I got from that is, if I2Cdev is using Wire instead of some alternative I2C library, I should include Wire.h. I really don't see why that's necessary, so I removed the line in which Wire.h is included, and got this error:

C:\Users\Franco2500k\Documents\Arduino\libraries\I2Cdev/I2Cdev.h:80:26: fatal error: Wire.h: No such file or directory
     #include <Wire.h>

So, apparently, I2Cdev.h already tries to include Wire.h, but somehow fails? And another #include a few lines later goes back in time and fixes everything? Can someone explain what is going on?


texts: Erratic behaviour using Serial.print() when powering only from power supply

texts:
I'm using an arduino uno with a thermal printer and the following code:

#include "Adafruit_Thermal.h"
#include "skull.h"
#include "SoftwareSerial.h"
int printer_TX_Pin = 8;  // This is the yellow wire
int printer_RX_Pin = 9;  // This is the green wire
Adafruit_Thermal printer(printer_RX_Pin, printer_TX_Pin);

void setupPrinter() {
  printer.begin();
};

void doPrint(char* output) {
  Serial.print("Will print: ");
  Serial.print(output);
  Serial.print("\n");
  printer.println(output);
  printer.feed(2);
}

void setup() {
  setupPrinter();
  doPrint("This is a test to see if it will print only from power supply");
}

void loop() {
}

That code works fine if the arduino and printer are plugged into 5v and the arduino is also plugged in to a computer with USB. Once I remove the USB cable it starts printing:

This is a test to see if it will
This is a test to see if it will
This is a test to see if it will
This is a test to see if it will
This is a test to see if it will

over and over infinitely. In other programs it prints a slightly garbled first line then stops. When I remove the serial.print lines, this doesn't occur. Why would that be?


texts: Connect two or more modules sharing the same pins?

texts:
I've found some separate instructions for connecting an SD reader/writer and also instructions for connecting a RFID reader and Piezo Buzzer.  I would like to use both modules and the piezo buzzer together on the same Arduino. See below for the pin wiring details from each instruction I found:

SD Reader/Writer

3.3v goes to 3.3v on the Arduino UNO (for power)
GND goes to Ground on Arduino UNO
D0 goes to pin 12 on Arduino UNO
D1 goes to pin 11 on Arduino UNO
CLK goes to pin 13 on Arduino UNO
D3 goes to pin 10 on Arduino UNO

RFID Reader

SDA - Digital 10
SCK - Digital 13
MOSI - Digital 11
MISO - Digital 12
IRQ - unconnected
GND - GND
RST - Digital 9
3.3V - 3.3V

Piezo Buzzer

Red - Pin 8
Black - GND

Is using the same pin for more that one module ok?


texts: ESP8266 http.get() issue due to wifi authentication failure

texts:
Facing a weird issue while reading data from esp8266.

I am trying to read dynamic data from a demo text file on test server on same network in deep sleep mode.

Case1: Joining new network

I am using WifiManager to join network and then followed by http.get()
However whenever i try to join the wifi with correct credentials it does not connect sometimes. Post some time ,if i try to wake the device it automatically connects and displays the data.

Case2: Rejoining existing network

Similar issue happens when i stop the test server and update the text file contents and up the server and try to read it on esp8266. It ask me the credentials again which it should have remembered 1st time. Post some time, if i try to wake up device sometimes it automatically connnects and prints updated value.

I am unable to figure out the problem here and its solution.
Any suggestion please.

#include <WiFiManager.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <Arduino.h>
#include <ESP8266httpUpdate.h>

ESP8266WiFiMulti WiFiMulti;
HTTPClient http;
WiFiManager manager;

  int publishPin = 0;
  int wifiPin = 5;
  unsigned int baud = 115200;
  const char* url3 = "192.168.43.215";
  const int httpsPort = 80;

  const String macValue = WiFi.macAddress();

 void publishData()
 {
    String link = "/one.txt";
    Serial.print("connecting to ");
    Serial.println(url3);

    http.begin("http://192.168.43.215/one.txt");

    int httpCode = http.GET();
    if (httpCode > 0) {
    if (httpCode == HTTP_CODE_OK) {
      Serial.println("This device is authorized!");
      Serial.println(http.getString());
      Serial.println(httpCode);

    }else {
    Serial.println("Failed to connect to API.");
    Serial.println(httpCode);
    return;
  }

  http.end();
  delay(1000);
}

void restPublish(){
  Serial.println("Rest publish");

  publishData();

}

void setup()
{
  Serial.begin(115200);
  Serial.println("setup2");

  manager.autoConnect("espdevice");
  restPublish();

 Serial.println("entering deepsleep now. DND");
 ESP.deepSleep(0);

}

void loop()
{
}


texts: Building RS485 serial to USB adapter with digispark

texts:
Is it possible to build an serial-adapter with digispark board?
Like: Embedded System with 2-wire RS-485 Port connect to my digispark board. Digispark Board is connected via USB to my Computer (running Linux tty or Windows COM Putty Interface)
I also own a Raspberry Pi. I'm very new at this thing, so maybe there is a way to convert the RS485 signals to monitoring my devices with my computer?


texts:
I tried to build project to detect alcohol with Arduino Uno and an MQ-3 Alcohol sensor.

I already have the R0 value, but I faced problem here: I don't know how to convert it to PPM or BAC. I already tried some code from tutorial for convert it to BAC but when I gave the sensor alcohol the code gives me a value of 0.00, and I don't know why.

Here is the code to find R0 value:

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

void loop()
{
    float sensor_volt;
    float RS; //  Get the value of RS via in a clear air
    float R0;  // Get the value of R0 via in Alcohol
    float sensorValue;

    for(int i = 0 ; i < 100 ; i++)
    {
        sensorValue = sensorValue + analogRead(A0);
    }

    sensorValue = sensorValue/100.0;     //get average of reading
    sensor_volt = sensorValue/1024*5.0;
    RS = (5.0-sensor_volt)/sensor_volt; //
    R0 = RS/60.0; // 60 is found using interpolation
    Serial.print("R0 = ");
    Serial.println(R0);
    delay(1000);
}

Here is the code to determine BAC:

float R0= 0.28;
void setup() {
  Serial.begin(9600);
}

void loop() {
  float sensor_volt;
    float RS_gas; // Get value of RS in a GAS
    float ratio; // Get ratio RS_GAS/RS_air
    float BAC;
    int sensorValue = analogRead(A0);
    sensor_volt=(float)sensorValue/1024*5.0;
    RS_gas = (5.0-sensor_volt)/sensor_volt; // omit *RL

   /*-Replace the name "R0" with the value of R0 in the demo of First Test -*/
    ratio = RS_gas/R0;  // ratio = RS/R0
    float a = pow(ratio, 2);
    float b = ratio/10;
    BAC = (0.1896*a) - (8.6178*b) + 1.0792 ;  //BAC in mg/L
    Serial.print("BAC = ");
    Serial.println(BAC*0.0001);  //convert to g/dL
    Serial.print("\n\n");
    delay(1000);
}

I would to know what's wrong with the code, and if you know how to convert the R0 values to PPM, please tell me.


texts: Non-blocking incrementation with single button pressure

texts:
I am looking for a way to increment a variable by one each time a button is pressed. Current approach is the following :

    if (redButton.isPressed())
    {
        a++;
        delay(100);
    }

isPressed() just return true if the pin state is HIGH.

delay(100) is used to compensate the small amount of time the button is being pressed. Otherwise a would be incremented multiple times in a single press. But it's blocking behavior, my program can't do anything else during that delay.

In short I'm looking to add a method in my Button class to detect if the button "has just been released".


texts:
I have created an arduino shield and i want to measure the voltage between the GND pin and 5V pins, to see if i see a voltage difference between the two points, in order to test if my pcb is fine.
My concern is since these are right next to each other and my multimeter probes are thick.
If the multimeter probe that 5V pin touches the GND pin, in other words, if i short circuit the 5V and GND pins, then will my arduino be safe?
I am afraid of damaging the arduino.


texts:
I'm trying to make a programm for Arduino Bluno Beetle, that saves a string in the loop. Here is my code:

#include <EEPROM.h>
#include <EEPROMAnything.h>
struct config_t{
   String lastThing;
    } savedValues;
void setup(){
   EEPROM_readAnything(ADDR, savedValues);
   Serial.println(lastThing);
}
String readString="asd";
void loop() {
 //...
 lastThing=readString;
 EEPROM_writeAnything(ADDR, savedValues);
}

(The EEPROMAnything.h can be found here: https://playground.arduino.cc/Code/EEPROMWriteAnything?action=sourceblock&num=1)

The code works until the 11th line. It gives there the following error:

'lastThing' was not declared in this scope

Does anybody know how to fix this problem?


texts: How to read data from Arduino with Raspberry Pi via I2C?

texts:
I have connected a Raspberry Pi 2 model B to an Arduino Uno via Bi-Directional Level shifter, from this BLOG:

Raspberry pi    GND    ----------   GND     Arduino
                3.3v   ----------   5v
                SCL    ----------   A5
                SDA    ----------   A4

I hope my I2C connection is correct.

And my Arduino is connected to an 8-Channel relay board.

Now I have written code in which I can control the relay board with the Raspberry Pi. For example, if I Press '1', relay 1 goes high.

Now I want to send data back from the Arduino to the Raspberry Pi in order to cross-check if relay 1 is high or not. If relay 1 is high then it should send some data back to the Raspberry Pi.

My Raspberry Pi code is:

import smbus
import time
# for RPI version 1, use "bus = smbus.SMBus(0)"
bus = smbus.SMBus(1)

# This is the address we setup in the Arduino Program
address = 0x04

def writeNumber(value):
    bus.write_byte(address, value)
    # bus.write_byte_data(address, 0, value)
    return -1

def readNumber():
    number = bus.read_byte(address)
    # number = bus.read_byte_data(address, 1)
    return number

while True:
    var = input("")
    if not var:
        continue
    writeNumber(var)
    number = readNumber()

My Arduino code:

#include <Wire.h>

#define SLAVE_ADDRESS 0x04
#define RELAY1 9

int number = 0;
int state = 0;

void setup() {
    pinMode(RELAY1, OUTPUT);
    Serial.begin(9600); // start serial for output
    // initialize i2c as slave
    Wire.begin(SLAVE_ADDRESS);
    // define callbacks for i2c communication
    Wire.onReceive(receiveData);
    Wire.onRequest(sendData);
    Serial.println("Ready!");
}

void loop() {
    delay(100);
}

// callback for received data
void receiveData(int byteCount){
    while(Wire.available()) {
       number = Wire.read();
       Serial.print("data received: ");
       Serial.println(number);
        if (number == 1) {
            if (state == 0){
                digitalWrite(RELAY1, HIGH); // set the LED on
                state = 1;
            } else {
                digitalWrite(RELAY1, LOW); // set the LED off
                state = 0;
            }
        }
    }
}

// callback for sending data
void sendData(){
    Wire.write(number);
}

Now if I type 1, and due to some loose connection relay 1 doesn't go high, I want the Arduino to take data from the relay board and send it to the Raspberry Pi every time.

It will be great if someone can explain also that how it works.

Hope I was able to explain the problem. I have done lots of research but was not able to find some answer.

I am a beginner in Python so please help me.

Thanks in advance.


texts: How to scroll data in LED dot matrix through multiple modules?

texts:
I've been struggling in this issue for a long time, I know there are people who have done it.

But, I don't have much experience in C to have the skills to design or develop such complicated functions.

I want to scroll data, e.g. text, chars or numbers just like the nice projects in YouTube about the dot matrix.

Like this one: How to Make a SCROLLING TEXT Display at Home

I know how to display a char, but I don't know how to scroll it. If I try I don't get the results I want.

This is my function for displaying chars:

void draw(void)
{
  s=0;
  uint8_t data_shift_buf;
  for (l=0;l<26;l++)            // to print 26 letters
  {
    for (row=1;row<9;row++)     // for 8 matrix rows
    {

        SPI_TX_m16(data = (row<<8) | (Alphabet[s]),4);// trying set data by column
        s++;_delay_ms(300);
    }
  }
}


texts:
Is it possible to send OTA updates to Arduino via nRF24L01+ module?

Here are my findings:

Here is an instructable explaining how to program Arduino wirelessly but this thing uses a BT module which shows up on PC as a COM port.

Here is something similar using Xbees.

However, these use another arduino attached to a PC on the other end. In my case, I am planning to use rPi hooked to another nRF24L01+ rather than PC.

This is an excerpt from the datasheet of Atmega chip:

  In ATmega88A/88PA/168A/168PA/328/328P the Boot LoaderSupport provides
  a real Read-While-Write SelfProgramming mechanism for downloading and
  uploading program code by the MCU itself. This feature allows flexible
  application software updates controlled by the MCU using a
  Flash-resident Boot Loader program. The Boot Loader program can use
  any available data interface and associated protocol to read code and
  write (program) that code into the Flash memory, or readthe code from
  the program memory.

Here is what I planned as a strategy.

Master programmer = Raspberry Pi + nRF module.

Slave arduino = Arduino + nRF24L01 + external EEPROM

Once I have to upload a new code, I can transmit the compiled code to the arduino (I can do that, right?) and Arduino will save it in the external EEPROM for the time being.

When the transfer is complete, I will send a signal which will make the arduino reset and copy the code from EEPROM to its flash memory.

My questions:

Is the strategy correct and feasible?

How should I proceed to achieve it?

Any other suggestions which you might have are welcome.


texts: it just gets too hot . any way of cooling it?

texts:
there i just got started with the arduino mega2560 . i tried 8x8 matrix tube and after ~30secs i found the atmega2560 a bit hot that i can melt a small amount wax on it ! is there any sort of heatsink or a better way to use the matrix tube ? what i have done is to turn on a led is to turn on the positive side and turn off the negative side . i just tried that method because in my 1st beginner kit , the manual said this should be done incase of a common anode rgb led .
thanks alot


texts: Arduino Nano burns with ESP-01 in parallel

texts:
So I have an Arduino Nano powered in parallel with an ESP-01 (for the ESP there is an extra LM1117-5.0 voltage regulator in series).

+12V ---------+---------+
              |         |
             Reg        |
              |        NANO
             ESP        |
              |         |
 GND ---------+---------+

My problem is that after a while, the Nano burns (my guess is the difference in current that both devices draw).

In any case, what could be the reason and what could I do to fix it?

Thanks!


texts: Why can't most servos rotate more than around 180°

texts: I was looking how a servomotor works. I realized that a standard servo can only turn up to 180°, but I didn't understand why. Is it because of the potentiometer?


texts: Can Chirp Waves be sent using JSN-SR04T?

texts:
So i have project for underwater rangefinding using JSN-SR04T. I've read on the datasheet that the module sends square waves. Is it possible to program it so that it sends Chirp waves instead ? (Help with the coding is very appreciated)
Thanks in advance


texts: Simple network protocol to communicate between N slave arduino and 1 central arduino?

texts:
i am looking to communicate text ( 40 char for each message ) between N arduino and a central one ( Communication is one way slaves to Master).I am looking for wire communication with 1 to 5 m distance.Does anyone know the best approach to do that ?

Vincent


texts:
I'm brand new to the Arduino world. I recently purchased a NodeMCU in order to have it act as a sort of foothold to get into Arduinos as it's something I've always wanted to do. However, it was only after I had received the NodeMCU that I realised that there was no default option in the Arduino IDE to flash to a NodeMCU and soon found out that this is because the NodeMCU is in fact not an Arduino and therefore has its own proprietary flashing software for .bin files. This initially confused me as an outsider as I assumed all devices of that nature must be Arduinos.

I recently came across a Homebridge plugin by affix called homebridge-mcu-lamp which uses a NodeMCU running an HTTP server to control a relay. Interestingly, the script he has included in the repository which he claims to have running on his NodeMCU is a .ino file which really confused me.

My question is: how would I flash a .ino file to a NodeMCU like the one mentioned above as I have no experience with .bin files and would much more value to treat the NodeMCU as an Arduino instead (i.e. programming in C++)?

I understand this may sound like a very simple/dumb question for most of you on this forum but it is something that has had me stumped for days and would really appreciate some guidance on.

I would also find it useful if someone could explain to me the difference between a NodeMCU and an ESP8266 as I see the two words being used interchangeably when referring to the same looking board.

This is what my NodeMCU looks like:


texts: Arduino Modbus Master code to read data using arduino uno from EB meter

texts:
I am using DC energy meter as slave.When I am testing DC energy meter using Modbus tester tool,its showing value from 1 to 24 register.I am using my own atmega328P with on board RS485 as a master device.I have connected A,B from slave to mater board.Now,I want to read slave outputs using my master.For that I have written below mentioned code.when I am serially printing array,its showing 00000000000000000000000000000000769.I am not getting full data on my master.

#include <ModbusRtu.h>

// data array for modbus network sharing
uint16_t au16data[64];
uint8_t u8state;

int i;

/**
 *  Modbus object declaration
 *  u8id : node id = 0 for master, = 1..247 for slave
 *  u8serno : serial port (use 0 for Serial)
 *  u8txenpin : 0 for RS-232 and USB-FTDI
 *               or any pin number > 1 for RS-485
 */
Modbus master(0,0,1); // this is master and RS-232 or USB-FTDI

/**
 * This is an structe which contains a query to an slave device
 */
modbus_t telegram;

unsigned long u32wait;

void setup() {
  master.begin( 9600 ); // baud-rate at 19200
  master.setTimeOut( 2000 ); // if there is no answer in 2000 ms, roll over
  u32wait = millis() + 1000;
  u8state = 0;
}

void loop() {
  switch( u8state ) {
  case 0:
    if (millis() > u32wait) u8state++; // wait state
    break;
  case 1:
    telegram.u8id = 1; // slave address
    telegram.u8fct = 3; // function code (this one is registers read)
    telegram.u16RegAdd = 1; // start address in slave
    telegram.u16CoilsNo = 24; // number of elements (coils or registers) to read
    telegram.au16reg = au16data; // pointer to a memory array in the Arduino

    master.query( telegram ); // send query (only once)
    u8state++;
    break;
  case 2:
    master.poll(); // check incoming messages
    if (master.getState() == COM_IDLE) {
      u8state = 0;
      u32wait = millis() + 100;
    }
    break;
  }
 //au16data[4] = analogRead( 0 );

 for(i=0;i<=64;i++)
 {
  Serial.print(au16data[i]);
 }
 Serial.println("\n");
 Serial.println("\n");
 delay(1000);
 }


texts: Smallest digital 3-axis gyroscope pcb for arduino?

texts:
What is the smallest size digital 3-axis gyroscope pcb compatible with an arduino that I can buy or maybe make if its simple enough. I need one really really tiny probably around 0.8x0.1x0.5 (doesn't have to be that small but the smaller the better).

Thanks,


texts: Arduino Nano (3.0) Use an USB Bluetooth stick

texts:
I was thinking to build a very small USB Audio Streaming device with aux output for an amp (I know they already exist, but I like the self invention). So I bought an Arduino Nano and a USB Bluetooth device with was originally for a computer. But I thought I might use it on the Arduino. After I removed the housing and soldered four wires onto the USB plug:

https://www.dropbox.com/s/ye5vveb98sfz1zq/IMG_20161030_132648_01.jpg?dl=0

I needed to know how to wire them:

https://www.moddiy.com/product_images/uploaded_images/patillaje-conector-usb.jpg

So I connected:

"1" to 5V+ on arduino
"2" and "3" need to be connected to txd and rxd on the arduino (but I don't know whitch way around)...
I read that I need to have 3.3v on "3" or the "+" wire but I have 5V Output on the digital Pins on the arduino (so I need some resistors, but I'm not familiar with calculating them).
"4" to gnd

Can someone confirm and / or provide some information for me to get this thing running (Bluetooth device enabled and functioning)?

Further steps would be:

coding the arduino to Use the Bluetooth module for audio streaming - preferrably three Channel.
configure the arduino to give the stream to an amp.

I know my knowledge of electronics is not very good and I need some education. If you can provide some good learning websites - feel free to suggest.


texts: Is there a way to set an interrupt to go off after a certain period of time?

texts:
I'm trying to save power by putting my device to sleep once it has run through the code once and turn it back on every 33 milliseconds. So basically, if the code finishes executing in 20 milliseconds the device can go to sleep for the remaining 13 milliseconds and it will be turned on by the interupt which is set to go off every 33 milliseocnds.

According to the documentation an interrupt is based on a change to the pin state, but I'm sure there must be a way to base it on time. If there isn't then is there a way to set the total time that a device sleeps? The sleep function seemed to just turn the device off, but can it be given a parameter to just turn off for a certain amount of time?


texts: How to read OC0A when in CTC (toggle) mode?

texts:
I have this code, which puts the Arduino into CTC mode with interrupts, and outputs a square wave on PD6 (OC0A):
void setup_timer(double p_ms, double duty){
  DDRD |= (1 << 6);  // set pin 3 as output
  TCCR0A = _BV(COM0A0); // toggle OC0A on Compare Match
  TCCR0B = _BV(WGM01); // set CTC mode WGM0[2,1,0] = 0b010
  TIMSK0 |= _BV(OCIE0A); // Enable CTC interrupt
  OCR0A = 128;  // set on and off time
  TCCR0B |= ( (0 << CS02) | (0 << CS01) | ( 1 << CS00)); // CS02:0 - No prescaling
  sei();
}

In the ISR (which is not shown) I want to be able to see whether OC0A (i.e. PD6) is HIGH or LOW.
I assumed that I could do a digitalRead(), but this post, Re: How to read the state of an output pin ? says:

Looking at the code the digitalRead() function just does a read of the appropriate bit in the appropriate PINx register without modifying anything, so it should work.
One catch, if it's a PWM pin the PWM will be stopped.

So, will the toggling of OCR0A be stopped?
This answer to How can I digitalRead a pin that is in pinMode OUTPUT? suggests reading PORTD directly, with
bitRead(PORTD,6);

However, will that work for PWM output or will PWM also be stopped by reading PORTD?

Addendum
I plan to use this code either as (primarily) a stand alone AVR µController (48/88/168/328 IC), but maybe in a Nano/Uno (if it will work) for testing purposes. I understand that using Timer0 will affect the operation of millis(), delay() etc., but the rest of the code will not rely on any of those functions... so I presume (maybe incorrectly) that the code will work as expected. Is that correct?
In addition, I don't intend on using a setup() & loop() program structure but rather main(). Just out of interest, would loop() work (i.e. is it reliant on Timer0)? I don't believe that it is.


texts: Changing pins used in ArduinoISP example

texts:
I have built my own ATTiny programmer, but made a bit of a mistake along the way - I didn't align the headers properly, and now instead of them plugging into pins 10, 11, 12 and 13 as per the ArduinoISP example - they now plug into pins 8, 9, 10 and 11.

If I use some jumper cables to wire the pins to match the ArduinoISP example, it all works fine, meaning the wiring on the actual board is OK, however, I want to be able to just plug my board I have made straight in, and thus need to get the bootloader burning and the uploading to work via pins 8, 9, 10 and 11 instead.

I have tried modifying the example myself by replacing the references to RESET, MOSI, MISO and SCK with my own pin numbers, but this doesn't seem to suffice. When I try to burn the bootloader now, I get the following error:

avrdude: stk500_program_enable(): protocol error, expect=0x14, resp=0x50
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

If I try to upload a sketch using my version which has the custom pin numbers, I get this error:

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

The wiring of my programmer is the same as can be found here: http://highlowtech.org/?p=1706 except I want the programmer sketch to work with different pins.

Thanks


texts:
I am using an Arduino Mega and a 12864ZW LCD with the u8glib library and the following code to draw to the LCD:

U8GLIB_ST7920_128X64 Display(LCD_E_PIN, LCD_RW_PIN, LCD_RS_PIN, U8G_PIN_NONE);

void loop(){
   Draw();
}

void Draw(){
   Display.firstPage();

   do{
      Display.setPrintPos(10, 10);
      Display.print("This is a test");
   }while(Display.nextPage());
}

The problem is that the display is constantly redrawing itself. When I used LCD displays in the past, they usually only required to write to the LCD once unless you wipe the display. When I adjusted the code to:

U8GLIB_ST7920_128X64 Display(LCD_E_PIN, LCD_RW_PIN, LCD_RS_PIN, U8G_PIN_NONE);
bool needsUpdate = true;

void loop(){
   Draw();
}

void Draw(){
   if (needsUpdate){
       Display.firstPage();
       do{
          Display.setPrintPos(10, 10);
          Display.print("This is a test");
       }while(Display.nextPage());
       needsUpdate = false;
   }
}

I do not get anything drawn on the LCD. Is there a parameter that needs to be set so I only have to redraw the LCD if something changes? Am I using an outdated library? Is there a better library I should be using?

EDIT

I think the main problem I have with using this library is does the Draw loop need to be executed continuously to display on the LCD or is there a way to only draw the screen once until it is needed to be drawn again?


texts: Unable to store data in variable from Serial.read()

texts:
I have a relay and bluetooth module connected to Arduino Uno. I send data such as digit 1 to the bluetooth module and I view it in the Serial Monitor. If I send 1 from serial monitor I get 4910 printed.

I would like to turn on the relay and have it stay on until I send a different digit. However, in my code below it doesnt work, the relay doesnt stay on.

Only, if I put the digital.write under while(Serial.available()) it works.

const int ledPin =  11;
int relayOn;

void setup() {

  //initialize serial port for logs
  Serial.begin(9600);

  pinMode(ledPin, OUTPUT);

}

void loop() {

  while (Serial.available()) {

      Serial.println("Data: ");

      Serial.println(Serial.read());

      if(Serial.read())
      {
        relayOn = Serial.parseInt();
      }

      while (relayOn > 1)
      {
        digitalWrite(ledPin, HIGH);

      }

    }

}


texts: ESP8266 problem with recieved data trasmission via TCP

texts:
I am having small project where I want to read couple of analog inputs from Arduino UNO, send it via software serial to ESP8266-01 and from that to python server using TCP.

Data is sent to ESP using this code on Arduino UNO

#include <SoftwareSerial.h>

    SoftwareSerial mySerial(10, 11); // RX, TX
    int pin = 5;

    void setup() {
      mySerial.begin(9600);
      delay(20000);
    }
    void loop() {
      delay(1000);
      int data = analogRead(pin);
      mySerial.println(data);
    }

Code on ESP is bellow

void loop() {
    while(Serial.available()>0){
    char data = Serial.read();
    client.print(data);
    }
}

When data is sent to Python server, it prints it out but data is sent in two seperate parts, so it always looks like this

9
59

, but number sent from arduino is just 959!

Python server code snipet:

while True:

        #Receiving from client
        data = conn.recv(1024)

        print data

        #send data to database
        post.create(
            current = str(data)
        )

         if not data:
            break

So the question is, why data sent to server is separated in two parts? Maybe it have to do something with how data is reading from serial on esp?


texts: What transparent casings are commonly used for smaller devices with a display

texts:
Not exactly Arduino-specific, but if you want to get a daily usable device (instead of a floating wire connection on your table) you eventually want to put your (Arduino-based) device into a nice casing. What are the different types of cases that people use?

I found soap cases as well as kitchen boxes (used one large cheese box from Mepal Rosti).


texts: Why does my Arduino freezes when i turn a servo

texts:
I have a Servo Motor and an Arduino Uno.

I used the Arduino to run a servo motor. The code was very simple. It was to just Turn it 90 Deg Anti-Clockwise when a switch is pressed and Turn back to its original position (90 Deg Clockwise).

The servo had 3 pins.
 1. V+
 2. Ground
 3. Data

I connected the V+ to the Arduino's 5v Output. And the Ground to the Arduino's GND pin. I connected the Data to Digital Pin 3.

When ever this script runs, The servo turns a little and then stops. It stops because the arduino froze and It wont do anything. I pressed the Reset button and it does nothing. I plugged off the Servo and the Power Supply and replugged the Power and it works.

The power source was a battery pack with 4x 1.5 Volts batteries in it. Maybe there was a problem with this?

Do anyone know what might be the problem here? Any Answer will be Appriciated. Thanks.


texts: How to add prefactor to clock frequency at compile time?

texts:
I want to use an Arduino Mega at 8MHz because my power supply is bad and I have only 4.3V (no way I can fix that), which is outside the operation range of the ATMega1280 at 16MHz. I think the right way to do it is to put a pre-factor 2 on CLKPR (tell me if I am wrong)? I know that several pages explain how to do so in a sketch: see How can you reduce the clock frequency of an Arduino Mega? , https://playground.arduino.cc/Code/Prescaler .

However, both those methods reduce the Mega frequency at run time, by setting the CLKPR register during the setup loop or another function, mess up with the millis(), delay(), Serial etc, and in addition I guess this means that the Mega is running at an out-of-spec 16MHz until the prefactor is set in the setup loop (?). So my question (I searched for it but found no answer) is:

Can one set the clock prefactor at compile time, so that:

the compiler knows about it,
the millis(), delay(), Serial and similar are not disturbed
the register is set immediately at boot (i.e. no need to change the registers in the setup)

?


texts:
I'm seeing something very strange. If I run:

ard-reset-arduino /dev/ttyACM0;
/usr/share/arduino/hardware/tools/avr/bin/avrdude -C/usr/share/arduino/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:`pwd`/.build/main.ino.hex:i;

Avrdude uploads my sketch to an Arduino Uno just fine. However, if I change the buadrate to 57600, it fails with the error:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

I've tried manually pressing the Arduino's reset button just before I upload, but there's no change.

Why is this happening? If I change it back to 115200 baud, it uploads fine...even though the sketch itself initializes the serial port to 57600.


texts:
I am trying to build a mobile device that turns itself on when removed from its usual location. I am attempting to do this with an Adafruit PN532 RFID reader and a MiFare card. Using the sample code I can detect when the card is present

success= nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
Serial.println("Scanning");
if (success){
  Serial.println("FOUND");
}

However, when I try to detect the absence of the card using the following code it will tell me "Present" over and over (since its in the Loop) while the RFID card is present but when it is removed it stops printing "Present" but never prints "Card Gone"

success= nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
    Serial.println("Present");
    if (!success){
      Serial.println("Card Gone");
    }

Is this a function of how Im using ! or is there something else at play here? I have found very few suggestions regarding detecting the absence of an RFID card and none of them seem to provide any useful answer. Most suggest some other hardware methodology as the solution. That is not the type of answer Im interested in for the moment. I would simply like to figure out why my code is incorrect.


texts: Error with Sparkfun MP3 Shield and Arduino Due playing music files

texts:
The code worked on my Ardino Uno. I plugged it up the exact same way and am now getting an error.

Here is the error I get when I try to upload my code to the due:

Arduino: 1.8.5 (Windows 10), Board: "Arduino Due (Programming Port)"

C:\Program Files (x86)\Arduino\libraries\SFEMP3Shield\SFEMP3Shield.cpp: In static member function 'static void SFEMP3Shield::refill()':

C:\Program Files (x86)\Arduino\libraries\SFEMP3Shield\SFEMP3Shield.cpp:1984:7: error: 'sei' was not declared in this scope

   sei();

       ^

C:\Program Files (x86)\Arduino\libraries\SFEMP3Shield\SFEMP3Shield.cpp:2006:9: error: 'cli' was not declared in this scope

     cli(); // allow transfer to occur with out interruption.

         ^

C:\Program Files (x86)\Arduino\libraries\SFEMP3Shield\SFEMP3Shield.cpp: In member function 'void SFEMP3Shield::SendSingleMIDInote()':

C:\Program Files (x86)\Arduino\libraries\SFEMP3Shield\SFEMP3Shield.cpp:2053:7: error: 'cli' was not declared in this scope

   cli(); // allow transfer to occur with out interruption.

       ^

C:\Program Files (x86)\Arduino\libraries\SFEMP3Shield\SFEMP3Shield.cpp:2067:7: error: 'sei' was not declared in this scope

   sei();  // renable interrupts for other processes

       ^

exit status 1
Error compiling for board Arduino Due (Programming Port).

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

Here is my code:

#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>

SdFat sd;
SFEMP3Shield MP3player;

const uint8_t volume = 10; // MP3 Player volume 0=max, 255=lowest (off)
//10 for normal 50 for testing

const uint16_t monoMode = 1;

void setup() {
  initSD();
  initMP3Player();
}

void loop() {
  if(!MP3player.isPlaying()){
    MP3player.playTrack(1);
  }
}

void initSD() {
  if(!sd.begin(SD_SEL, SPI_HALF_SPEED))
    sd.initErrorHalt();
  if(!sd.chdir("/"))
    sd.errorHalt("sd.chdir");
}

void initMP3Player() {
  uint8_t result = MP3player.begin();
  MP3player.setVolume(volume, volume);
  MP3player.setMonoMode(monoMode);
}


texts: Arduino UNO/ZERO PRO, enough computing power for PID-controller?

texts:
I am currently working on a project, where I design a PID-Controller for a 2-axis stabilization with brushless-propeller-motors.

My question is: Does an Arduino UNO have enough computing power to perform this task in a useful manner? Arduino UNO Specs

And secondly: If the UNO was really too slow for this task, would the newly released Arduino ZERO PRO perform at an acceptable rate? Arduino ZERO PRO Specs

Thanks for your help and inputs in advance!


texts:
I have a Yun and I'm trying to change the URL I type in to access the Web UI.

I've successfully changed its hostname in /etc/config/system, which now lets me SSH in using the new name. However:

Going to newname.local doesn't work (no response at all).
Going to arduino.local pulls up the green page 'Wait a moment or click here...', after which no page is rendered.

How can I access my Yun by typing in newname.local in my browser?


texts:
i'm using arduino ide 1.8.12 opened preferences window and did enter

http://arduino.esp8266.com/stable/package_esp8266com_index.json, https://arduino.esp8266.com/stable/package_esp8266com_index.json

(all comma separated) into the Additional Board Manager URLs field. then i opened the boardmanager (Strg+Shift+I) and enter 'esp' in the search field. BUT I CAN'T FIND "esp8266 by ESP8266 Community". it's not listed. WHAT CAN I DO NOW ?

additive : is there a way to include a locally available json file in the arduino as a library?
the file
    package_esp8266com_index.json
is in the directory
    C: \ Users \ [user] \ AppData \ Local \ Arduino15

thanks in advance


texts: Will writing to serial when no serial is available cause problems?

texts: I have an Arduino UNO, and use the serial for debugging purposes. What happens if I run the arduino on batteries and try to write to serial? Will the code stop running until a serial connection is availible?


texts: Using 4 identical sensors on the I2C bus

texts:
I am using 4 Pololu VL6180X ToF sensors on the Arduino UNO for a school project but just can't seem to get it working correctly. I understand that I need to hold them in reset and change the I2C address of each sensor after waking them up, but the code I have doesn't work. Is the problem some flawed understanding of the C language?

This is the .h file I wrote (distSensors.h):

/*
This module is used to interface with the distance sensors.
*/
#ifndef DISTSENSORS_FILE
#define DISTSENSORS_FILE

#include "vl6180x/VL6180X.h"
#include "globals.h"

// pins connected to VL6180 GPIO used to hold sensor in reset
#define NORTH_SHUTDOWN 13
#define EAST_SHUTDOWN 1
#define WEST_SHUTDOWN 0

// threshold distance for detectWall (mm)
double const WALL = 70;

// initializes sensor
void initSensor(VL6180X* sensor) {
  (*sensor).init();
  (*sensor).configureDefault();
  (*sensor).setTimeout(500);
}

void changeAddress(VL6180X* sensor, int address) {
  (*sensor).setAddress(address);
}

// sensors
VL6180X sensorNorth;
VL6180X sensorSouth;
VL6180X sensorWest;
VL6180X sensorEast;

void setupSensors() {
  // shutdown pins
  pinMode(NORTH_SHUTDOWN, OUTPUT);
  pinMode(WEST_SHUTDOWN, OUTPUT);
  pinMode(EAST_SHUTDOWN, OUTPUT);

  // hold each sensor in shutdown initially
  digitalWrite(NORTH_SHUTDOWN, LOW);
  digitalWrite(WEST_SHUTDOWN, LOW);
  digitalWrite(EAST_SHUTDOWN, LOW);
  delay(10);

  digitalWrite(NORTH_SHUTDOWN, HIGH);
  digitalWrite(WEST_SHUTDOWN, HIGH);
  digitalWrite(EAST_SHUTDOWN, HIGH);

  digitalWrite(NORTH_SHUTDOWN, LOW);
  digitalWrite(WEST_SHUTDOWN, LOW);
  digitalWrite(EAST_SHUTDOWN, LOW);

  // wake sensors and change address one by one
  // south is never shutdown, and its address is changed first
  changeAddress(&sensorSouth, 0x23);
  delay(10);

  digitalWrite(WEST_SHUTDOWN, HIGH);
  changeAddress(&sensorWest,0x25);
  delay(10);

  digitalWrite(EAST_SHUTDOWN, HIGH);
  changeAddress(&sensorEast, 0x27);
  delay(10);

  digitalWrite(NORTH_SHUTDOWN, HIGH); // NORTH maintains default address

  // init all sensors
  initSensor(&sensorNorth);
  initSensor(&sensorSouth);
  initSensor(&sensorWest);
  initSensor(&sensorEast);
}

// Return the distance reading from the given direction
double getDist(int direction) {
  switch (direction) {
  case NORTH:
    return sensorNorth.readRangeSingleMillimeters();
  case SOUTH:
    return sensorSouth.readRangeSingleMillimeters();
  case WEST:
    return sensorWest.readRangeSingleMillimeters();
  case EAST:
    return sensorEast.readRangeSingleMillimeters();
  }
}

// return 1 if there is a wall, 0 if there is not a wall
int detectWall(int direction) {
  if (getDist(direction) <= WALL) { return 1; }
  else { return 0; }
}

#endif

And this is the test code I'm running:

#include "distSensors.h"
#include "Wire.h"
void setup() {
  // put your setup code here, to run once:
  Wire.begin();
  setupSensors();
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("NORTH: "); Serial.println(getDist(NORTH));
  Serial.print("SOUTH: "); Serial.println(getDist(SOUTH));
  Serial.print("WEST: "); Serial.println(getDist(WEST));
  Serial.print("EAST: "); Serial.println(getDist(EAST));
  delay(100);
}

getDist returns 0.0 for every sensor except for sensorSouth.

Any help would be greatly appreciated, thanks!


texts:
I appreciate if someone can help me.
I have a function that counts the time and I would like to store values according to the day.

For example: day_7.11.2015 = [gain = 100.23, cost = 78.0 ...]
              day_8.11.2015 = ...

I do not know how can I create an array with these values taking as input the day, month and year. Does anyone have any idea?

String test = "day_" + String(day) + "." + String(month) + "." + String(year);
float String(test)[] = {11.2, 10, 20, 31.2};
 Serial.println(test);

Thanks a lot!


texts: How to improve the sampling rate of Arduino due ADC?

texts: I am now working on a project, which needs a cheap analog acquisition device with a sampling rate of no less than 5MHz. Before, I only used Arduino, and rarely operated the registers on Arduino. I hope to use Arduino due to complete it. I spent a lot of time researching and querying solutions, but it didn't succeed. I hope someone can help me.


texts: What is the maximum SPI speed for a slave Uno/clone?

texts:
I have a Rapsberry Pi master sending SPI requests to an Uno Chinese clone slave : I send 16 characters to the Arduino, which answers 16 others characters. What I send is not important, it's the Arduino answer that matters.

When I set the speed on the Raspberry Pi at 1 Mbit/s with my C program, the received answer coming from the Arduino is mostly garbage (random characters), but this issue disappears with lower speeds.

So that leads me to this question : what is the maximum SPI speed for a slave Uno/clone, in order to have no errors ?

Edit : the Arduino code :

#include <SPI.h>

char receivingBuffer[5];
char sendingBuffer[5] = {'T', 'e', 's', 't', '!'};

volatile char bytes_received = 0;

void setup()
{

  SPCR |= bit(SPE);

  pinMode(MISO, OUTPUT);

  SPI.attachInterrupt();

  SPDR = sendingBuffer[bytes_received];

}

ISR(SPI_STC_vect)
{

  if (++bytes_received == 5)
  {

    bytes_received = 0;

  }

  SPDR = sendingBuffer[bytes_received];

}

void loop()
{

  //

}

Also, the C code on the RPi :

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wiringPiSPI.h>

#define SPI_CHANNEL 0
#define SPI_SPEED   1000000 // Hz.

int main(void)
{

   wiringPiSPISetup(SPI_CHANNEL, SPI_SPEED);

   while (1)
   {

      char buf[5] = {'T', 'e', 's', 't', '?'};

      printf("Sending   : %s\n", buf);

      wiringPiSPIDataRW(SPI_CHANNEL, buf, 5);

      printf("Receiving : %s\n\n", buf);

      sleep(1);

   }

   return 1;

}


texts:
I am trying to work with arduino timer1 interrupts to make an led blink every bit on an 8 bit number, depending on whether its a 1 or 0. However, im trying to make a basic blinking program, and it does not seem to be working.

#include “TimerOne.h”
bool val=0;
void setup()
{
    pinMode(13, OUTPUT);
    Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period
    Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt
}

void callback()
{
    val=1;
}

void loop()
{
    digitalWrite(13,val);
    while(!val);
    val=0;
}

The LED doesnt blink at all! Any help would be appreceitated!
thanks!


texts:
Trying to get this code to work on the VoiceBox Sheild but failing badly.
I'm a total newbie here - have uploaded it and plugged in the potentiometers as per this diagram, but without success
Is it just a case of changing some of the pin details? Please help!


texts:
Is it considered possible to use the esp32 code on an esp32 cam board? Do they use the same hardware? I am having difficulty using this sketch https://gist.github.com/wybiral/2a96c1d1605af7efa11b690586c4b13e on my esp32 cam and I think it is because it was designed for an esp32 board.

Thanks,
Dave


texts: SdFat library Change output style of sd.ls(LS_R)

texts: I'm using the SdFat Library's sd.ls(LS_R) function to give me a serial output stream of all files on an SD card. My issue is that I would like to have it use a different character than '\n' at the end of each line as I'm using it as a termchar for my overall comms protocol. How can I get it to print a : or (another symbol that doesn't appear in file names) instead of a \ln


texts:
I have bought two original TowerPro MG966R 360 degree continuos rotation Hi-torq digital servos.
Expected results :

90       deg -- no rotation
90 - 0   deg -- speeding up to one side
90 - 180 deg -- speeding up to the other side

Real results :

When I am sending 50-90 degrees PWM, they behave like standard (non-continuos) servos and turn in 50-90 degree angle.
Bellow 50 there is small speedup, then continuos rotation at max speed to one side.
Above 90 there is continuos rotation at max speed to the other side.

I am using standard Arduino Servo library,
servo has external 2A power and
all grounds (servo, arduino, power) are connected together.
Both new servos behave same, so I assume fault is on my side (software).
Same code and wiring works fine with other (cheap,copycat) servo I have.
May I ask for some pointer to what am I doing wrong?
Thanks
My test code :
    // 9 - servo pin
    // 2 - pot pin

    #include <Servo.h>

    Servo srv;

    void setup(){
        srv.attach(9);
    }
    void loop(){
        //~ srv.write(map(analogRead(2),0,1023,50,90));
        srv.write(map(analogRead(2),0,1023,0,180));
        delay(10);
    }

Bought here : ebay
Manufacturer page : here


texts: Is the Arduino bootloader really the Atmel bootloader? Can I use Flip to upload?

texts:
I've been asked to do a small project using an Ada BlueFruit board. It has a ATMega32U4. The 32U4 comes from the factory with a bootloader pre-installed. I've never used an Arduino before, but I have used AVR a bit in the past. Is the Arduino bootloader actually the one that came pre flashed from the factory? Does it even matter if it's the same bootloader as far as Flip is concerned?

Can I use the Flip batchisp utility to load my application code? We don't have a programmer handy and I don't want to muck up the bootloader on the board.

It's my understanding that the Arduino IDE tool chain does a bit of preprocessing "behind your back". I'd much rather continue writing straight AVR code in Atmel Studio. Is there anything I need to take into account when writing my application code? For example, do I need to do anything when compiling my app code, or when uploading it, to ensure it doesn't try to write to the memory addresses in the bootloader's range?


texts: Updating mysql data using SIM900 and Arduino

texts:
Thanks in advance for your kind support.
I am not an expert but have little understanding of concepts and trying to integrate various things to get some useful projects for my purpose. I want to update the database (MySQL) on shared hosting using the SIM900A module and Arduino nano board. With help of examples shared on this platform and my understanding, I achieved a significant part of the same.  The following is the approach I have adopted and the current status:
I have put a PHP code on the server (shared hosting) to update the database once it received the GET request
I have also uploaded the code in the Arduino with proper connections for sending requests to the server.
Problems I am facing:
I am not able to update the data on my specific database, through the Arduino sent request. the same code is working with Thingspeak, My code is also working otherwise, as I have tested through web form request and URL request. I am not sure where is the problem.  I am also not getting any errors. The response to the AT request is "OK" only
Though I can update the Thingspeak channel, only till the command lesser than 61 characters, which are sent after the AT+CIPSEND command. There is no error, even if the request size increases, but data updated only till 61 characters (including \x1A character)
"I am wondering, is this the limit, that cannot be increased or there is some possibility to increase it."
I understand that the problem appears to be in approach and not in code, as the code is working in itself. However, please let me know, which code I need to share, as it is a multifile code on the web-editor


texts: Individually addressing LEDs in a multiplexed matrix

texts:
I have created my first LED project with a hand made 4X4 LED matrix. The cathodes are joined horizontally to make the rows and the anodes are joined vertically to make the columns the columns. It is controlled by a shift register with the cathodes (rows) connected to pins 0-3 and the anodes (columns) connected to pins 4-7 of the register controlled from an Arduino Nano.

It all works but I have hit upon a limitation that I have not seen in the various videos and tutorials about making LED matrices so I suspect I am missing something.

This code will light up the bottom left LED which I will call position (0,0).

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, B00011110 );
digitalWrite(latchPin, HIGH);

This code will light up the LED at position (1,1), so one up and one to the right.

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, B00101101 );
digitalWrite(latchPin, HIGH);

If I then combine the two as below:

digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, B00111100 );
digitalWrite(latchPin, HIGH);

it of course lights up 4 LEDs: (0,0),(0,1),(1,0) and (1,1).

This feels like a limitation of wiring the LEDs in this way because once you power a row in a given column, you cannot unpower it in subsequent columns or vice versa. i.e. lighting (X,Y) and (A,B) means that you cannot have (X,B) and (A,Y) unlit.

However, in the videos I have seen that accompany tutorials on how to make similarly constructed matrices, I can see them lighting up in ways I can't replicate.

How can I light up an LED at positions (0,0) and (1,1) without also lighting up (0,1) and (1,0)?

Is this possible with this configuration?


texts: Issue with Indenting the Serial Print data in the Serial Monitor

texts:
I have a question with Serial Print. I want the Sensor reading values to fall under 3 columns, and each column should have the readings from the same sensor.

Raw Value |    Sensor 1 |   Sensor 2  |   Sensor 3

how can I modify this code do this?

Below I have posted my code and what I currently see using the Serial Monitor

    void loop(){

  RawValue0 = analogRead(analogIn0);
  Voltage0 = (RawValue0 / 1023.0) * 5000; // 5000 to get millivots.
  tempC0 = (Voltage0-500) * 0.1; // 500 is the offset
  tempF0 = (tempC0 * 1.8) + 32; // conver to F
  Serial.print("Raw Value = " );  // shows pre-scaled value
  Serial.print(RawValue0);
  Serial.print("\t milli volts = "); // shows the voltage measured
  Serial.print(Voltage0,0); //
  Serial.print("\t Sensor 1: Temperature in C = ");
  Serial.print(tempC0,1);
  Serial.print("\t Sensor 1: Temperature in F = ");
  Serial.println(tempF0,1);
  delay(500);


texts: Arduino Uno R3 not working after shorting 5V to GND

texts: While wiring up my new Arduino Uno R3 on a proto-board, I accidentally shorted the 5V pin directly to Ground. The LED's immediately turned off and connection was lost. It was powered by USB connection. After 3-5 seconds I removed the short. The LED's have remained out, and I haven't been able to reestablish connection with my computer since. I've unplugged and re-plugged the USB cable and tried the re-set button plenty of times. This short shouldn't have fried the board...  what happened? How can I get my Arduino working again??


texts: Tapered log potentiometer to linear formula

texts:
I have a tapered log 10K potentiometer. I would like some function which returns tapered log value to linear values.
The potentiometer is a slider. When connected to the Arduino the wiper displays the values ranging from 0 to 1023.  Currently if I set the slider to the half way position it displays the value 856 (approx), when I'd expect (or want) the value it to be more like 512 (as it's half way). The quarter way mark for example shows a value in the region of 570, where I'd expect the value to be 256. I hope that this makes sense.

This is about the extent of the code so far :))

  curpos1 = analogRead(potPin);

  Serial.println(curpos1);


texts: Power Supply Problem with Arduino Yún: Using a log USB cable

texts:
I want to use an Arduino Yún as a kind of outdoor weather station. I want to supply the power for the Yún with a 5V USB-Charger. Using a normal USB cable everything works fine. But as the weather station shall be far from the next power socket, I made the USB cable about 10 meters longer. Now the Yún does not power up any more.

Has anybody an idea why?

Should I use a 12 V power supply and a 7805 power converter instead?


texts: Send data to API from Arduino with ESP8285 Strange Error

texts:
I have an Arduino with few sensors, and I want to send all of data to my API over ESP8285 what is connected to the wifi.

Its almost working fine, except one thing.

I have these AT commands:

String postRequest =
    "POST /hello HTTP/1.1" + String("\r\n") +
    "Host: 192.168.88.186" + "\r\n" +
    "Cache-Control: no-cache" + "\r\n" +
    "Content-Type: application/x-www-form-urlencoded" + "\r\n" +
    "Content-Length: " + String(data.length()) + "\r\n\r\n" +
    String(data) + "\r\n";

void connectWifi()
{
  espclient.println("AT+CWMODE=1");
  String connectcmd = "AT+CWJAP=\"" + ssid + "\",\"" + w_password + "\"";
  espclient.println(connectcmd);

  delay(3000);
  if (espclient.find("OK"))
  {
    Serial.println("Connected!");
  }
  else
  {
    connectWifi();
    Serial.println("Cannot connect to wifi");
  }
}

void espStatus()
{
    String tmpResp = espclient.readString();
    Serial.print("ESPLOG:");
    Serial.println(tmpResp);
}

void httppost()
{
  espclient.println("AT+CIPMUX=0");
  espclient.println("AT+CIPSTART=\"TCP\",\"" + server + "\",5000"); //start a TCP connection.
  if (espclient.find("OK"))
  {
    Serial.println("TCP connection ready");
  } else {
    espStatus();
  }
  espclient.println("AT+CIPSTATUS");
  espStatus();

  Serial.println("PRINT REQUEST ==================================");
  Serial.println(postRequest);
  Serial.println("PRINT REQUEST ==================================");

  espclient.println("AT+CIPSEND="+String(postRequest.length()));
  do {
    delay(1000);
    if (espclient.find(">"))
    {
      break;
    }
  }
  while(true);
  espclient.print(postRequest);
  delay(500);
  espStatus();
  espclient.println("AT+CIPCLOSE");
}

SETUP:

void setup() {
  Serial.begin(9600);
  Serial.println("Starting the modules....");

  espclient.begin(9600);
  connectWifi();
  Serial.println("ESP Module is ready");
}

LOOP:

void loop() {
    httppost();
    delay(5000);
}

And I get this error(?) message:

TCP connection ready
ESPLOG:
AT+CIPSTATUS

STATUS:2

OK

PRINT REQUEST ==================================
POST /hello HTTP/1.1
Host: 192.168.88.186
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Content-Length: 13
name=ESPModul

PRINT REQUEST ==================================
ESPLOG: Q�J5U�S�!*HZYlo QQA��HV�^\��
H��銒)       �&�C��y \�R
�r�+����H�

TCP connection ready
ESPLOG:
AT+CIPSTATUS

STATUS:2

OK

PRINT REQUEST ==================================
POST /hello HTTP/1.1
Host: 192.168.88.186
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Content-Length: 13
name=ESPModul

PRINT REQUEST ==================================
ESPLOG: Q�J5U�S�!*HZYlo QQA��HV�^\��
H����)      �&AC��y \�R
�r�+����H�

UPDATE The new /error/ message:

ESPLOG:Q�J5U�SS�CT��he���EE))���H��
����    )�H��HK�
Ca����E�K�V,YCCb

UPDATE2 I restarted the arduino, and now I am getting this:

TCP connection ready
PRINT REQUEST ==================================
POST /hello HTTP/1.1
Host: 192.168.88.186
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Content-Length: 13

name=ESPModul

PRINT REQUEST ==================================
ESPLOG:
AT+CIPSTATUS

STATUS:2

OK
AT+CIPSEND=155

link is not vAT+CIPCLOSE

ERROR

UPDATE3: This method is working

void testHTTP()
{
  Serial.println("Establishing TCP connection");
  espclient.println("AT+CIPSTART=\"TCP\",\"" + server + "\",5000");
  delay(1000);
  Serial.println("Sending out data…");
  espclient.println("AT+CIPSEND=16");
  espclient.println("GET / HTTP/1.1");
  espclient.println();
  espclient.println("AT+CIPCLOSE");
}

If I connect the ESP to my PC with TTL adapter, and I write the commends manually, then its working fine. And yes, the ESP is connecting correctly to the wifi, I tested it.

The main solution was to put "delay(1000);" after "CIPSEND=".

I hope my fumbling can help to someone in the future.


texts: GPS - Speed doesn't update as should - EM408 & Arduino Mega & GSM

texts:
I'm developing a system that will get the GPS signal and send it though the GSM with information about position, speed and temperature from some digital sensors.

Currently I'm using the GPS EM408, the Arduino mega plus the GSM board (official one).

The problem is that the GPS (by the library TinyGPSPlus) gives me the same speed for long time or sometimes give me 0km/h.

The sketch works like this:

loop()
{
   getGPSData() - ~ 1 sec to execute and take one data from the GPS.
   getSensors() - ~ 1 sec to execute and take one data from the digital sensors.
   sendData() - ~ 6 n 10 secs to send the data through the internet.
}

The whole process takes around 10 ~ 15 secs to be completed.

If I remove the sendData() and the system starts getting the GPS information each second the speed value works perfectly but if I get the data from the GPS each 12 secs (because of the GSM delay) the speed doesn't work as expected.

I understand that the problem is because the library TinyGPSPlus calculate the speed between two points and the getGPSData() only takes one information each loop and the next point has 15 secs of difference.

Although I've added a "for(i=0;i<=4;i++)" to the getGPSData() enforcing it to get at least 4 times of position before the GSM send it over the internet, now is working better but still getting the wrong value or sometimes it freezes to the same speedy for long time.

I've tried to add a second board and put both to communicate with I2C turning it "dual core", where one board will be getting the data from the GPS each second and another one will send though the data each 15 secs, but the GSM freezes sometimes when the I2C is connected :(.

Does anyone has any clue how to do it?


texts: Use lowpower-libary and still use serial connection and other things

texts:
I managed to get the LowPower libary working on my Arduino Micro. This code works perfectly:

#include <LowPower.h>

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);                  // wait for a second
}

However. I also tried it with a serial connection, to put out some text periodically. But I think the lowpower-libary does - in order to save power - disable this function. So now I am worried that it also disables some other things I might have to use but won't work. Like OneWire or I2C. It also would be nice to work with a functioning standby-mode while developing where serial output is vital, altough it's not neccessary, because I can simulate it with a simple delay. So my question is: How can I use the lowpower-libary AND have a serial connection. And will this libary affect OneWire or I2C? If so: Is there a way on how to keep these "services" running? Or is there maybe another libary wich also saves power in a similar way, but where you have more abilities to customize what you want to have shut down?


texts: I am thinking forward to buy a set of Arduino pro mini. I have a very low budget and I can't think of buying a FTDI board. Is there any substitute for the FTDI board that is compatible with these arduino pro mini.


texts:
I am trying to execute some webbased calls, but my string keep "disappearing", and I am highly confused about why.

I can println a string directly, but if I have it in a variable, it will disappear :I

I tried googling around, but could not find a reason for it. Is it because of the curly brackets ? Is it a memory issue ?

I feel I really can't code on and juggle web calls, if I can't even handle regular string commands..

Code:

Serial.println(" - CONSOLE/STRING WEIRDNESS - ");
String message = "Testing time {0}";
Serial.println(message);
Serial.println(String(message));
Serial.println("Testing time {0}");
Serial.println(message.substring(3,6));

Response:

- CONSOLE/STRING WEIRDNESS -
(nothing)
(nothing)
Testing time {0}
(nothing)

Update

This seems to happen whenever there is a number inside a string, it even happends with a simple string like this:

Code:

Serial.println(" - CONSOLE/STRING WEIRDNESS - ");
String message = "Testing time here is a number 0";
Serial.println(message);
Serial.println(String(message));
Serial.println("Testing time here is a number 0");
Serial.println(message.substring(3,6));

Response:

- CONSOLE/STRING WEIRDNESS -
(nothing)
(nothing)
Testing time here is a number 0
(nothing)


texts:
I saw a project on the Internet (the one in the photo), and I wonder, would it be a problem for me to connect the Vin and GND of the Arduino to the same place where the Servo Motors are being powered? (to power the Arduino together without having to connect it to another source or USB)

And if instead of the batteries I use one of those Breadboard Power Module (photo two) and connect a 12V / 1A power supply in it, would it have problem ? (connect the 4 Servo + the Arduino in it)


texts: What components I need for a small GPS tracker

texts:
I am new to Arduino and want to create a graduation project for my university.
I am thinking to create a GPS tracker that can be attached to a cloth to track kids, for example.
So the requirements for this project is as follows:
- The device should be small
- It should upload its location to a web server constantly.
- the device should work with battery for at least 8 hours

Now what components are needed for this project?
What concern me a lot is that how can I find battery last this much time, if I need bigger battery, it may hinder the device from being attached easily.


texts: Linux can not open arduino IDE - java.lang.NullPointerException

texts:
I use arch linux. I installed arduino ide with pacman. When I try to run it, loading window will show for few socends and than program crashes. There are logs:
john@arch-thinkpad ~ [1]> arduino
Picked up JAVA_TOOL_OPTIONS:
Set log4j store directory /home/john/.arduino15
java.lang.NullPointerException
    at processing.app.Base.rebuildProgrammerMenu(Base.java:1705)
    at processing.app.Base.<init>(Base.java:286)
    at processing.app.Base.main(Base.java:150)
john@arch-thinkpad ~ [255]>

john@arch-thinkpad ~> arduino --version
Picked up JAVA_TOOL_OPTIONS:
Loading configuration...
Initializing packages...
Preparing boards...
Arduino: 1.8.13

What should I do to fix it ?
Thank you for your help


texts: Serial communication between arduino and raspberry pi works once, then stops working

texts:
I'm using a Arduino Uno Rev 3 connected over usb to a Raspberry Pi Modell B+ running Rasbian.

Here ist the arduino code:

int input = 0;
String command = ""; // beinhaltet den aktuellen befehl
int Action = 1;

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

void loop() {
  if (Serial.available() > 0)
  {
        input = Serial.read();
    char currentChar = input;

    if(currentChar  == '!') // frage nach trennzeichen
    {
      Serial.println(command);
      //Serial.write(Action);
      Action = command.toInt();

      command = ""; // befehl wieder leeren
    }else
    {
      command = command + currentChar ; // falls noch kein trennzeichen vorhanden, erweitere kommando
    }
    }
}

Here is the Raspberry Pi code (in python)

import serial
from time import sleep as sleep
ser = serial.Serial('/dev/ttyACM0',9600)
s = [0]
while True:
        ser.write(b'2!')
        a =  ser.read(1)
        print a
sleep(2)

It always works if once after the code was uploaded to the arduino, but if I stop the script on the pi and restart it it stops working. What is the problem here?