texts: Arduino controlling WS2818 7-Jewel LEDs displaying random behaviour

texts:
This is my first Arduino project.
I have bought some components to make some lamps with. I have an Elegoo Uno R3 Arduino controller for them. The LEDs are from a Chinese company called DIYMall and are all WS2812 7-Jewel type (circular rings with 6 in the circle and 1 in the middle). I have a 5v power supply from my breadboard running to the power on the LEDs and the data is coming from the Arduino. I have a 470ohm resistor in the data line and a 1f capacitor on the power bus too, both as dampeners (as recommended on one of the official Arduino tutorials). The wiring isn't soldered -- I'm just using jumpers.
I have some simple code to rotate a light around the ring.
#include <Adafruit_NeoPixel.h>

#define PIN 2
#define NUM_LEDS 7

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show();
}

void loop() {
  int color = 10;
  for(int pixel = 1; pixel < 7; pixel++) {
    strip.setPixelColor(pixel, color, 0, 0);
    strip.show();
    strip.setPixelColor(pixel, 0, 0, 0);
    delay(100);
  }
}

(source is on GitHub: https://github.com/BryanDollery/arduino-rotating-ws2812-ring)
The problem I'm having is that the results are terrible. Random LEDs light up, the middle one (LED 0) lights up and flashes random colours all the time, and it keeps freezing for around a second. I have made a video of the effect here: https://www.youtube.com/watch?v=g4enns1v0Ys
I started the project without the dampeners and added them to suppress any noise in the system, but that didn't help. I think I need some help working out what's going wrong. It could be the LEDs -- I've tried 3 units so far and they all do the same thing, so if its a manufacturing fault it's affecting them all.
Note: I've read that the ground should be connected from the power supply to the uno. I've tried connecting -ve from my breadboard to my uno gnd and it shorted my power block and melted it, so I've not tried that again. I suspect the lack of this circuit is causing the problem but I don't know how to fix it. I have used the 5v +ve and gnd from the uno with no problems at all, but I need to get this working with an external power supply.
I haven't tried this with my R-PI yet, but I'll give that a go and report back if it's any more successful.
TIA


texts: NodeMCU ESP8266 12E loses code after power is reconnected

texts:
I have uploaded a simple code to control a 8 channel relay by turning individual relays on and off
When I upload the code it works properly, the code works properly and the relays turn on and off in the desired pattern. However when i disconnect the USB cable from my computer and reconnect it, the code isnt working anymore, there is no visible action happening. Is the code erased from memory after power is cut?

int pins[] = {D0, D1, D2, D4, D5, D6, D7, D8};
int i;

void setup()
{
  Serial.begin(115200);
  for(i=0;i<8;i++)
  {
    pinMode(pins[i],OUTPUT);
    digitalWrite(pins[i],HIGH);
  }
}
void loop()
{
  for(i=0;i<8;i++)
  {
    digitalWrite(pins[i],LOW);//Turns this relay on
    Serial.println(pins[i]);
//Turn the previous relay off
    if(i==0)
    {
      digitalWrite(pins[7],HIGH);
    }
    else
    {
      digitalWrite(pins[i-1],HIGH);
    }
    delay(700);
  }
}

My circuit:
NodeMCU | Relay
D0 IN1
D1 IN2
D2 IN3
D4 IN4
D5 IN5
D6 IN6
D7 IN7
D8 IN8
Vin VCC
GND GND


texts: Is it possible to upload a file with GPS values onto my arduino?

texts:
I am absolutely new at arduino but ok with writing code. I am trying to upload 20 points of interest lat/long as a static file that sits on my arduino. Then I want to use my GPS sensor and a function which uses the haversine formula to constantly measure distance between all 20 points and the GPS data from the arduino and output the distance to the nearest point on an LCD screen.

I cannot figure out how to store and reference that list of GPS points of interest.


texts:
I've written a simple sketch that adds threshold to an PIR sensor. If the PIR sensor sends 3 HIGH ex. HIGH...LOW...HIGH...LOW...HIGH (The LOW == no movement) it will trigger and alarm.

I want to reset the counter of HIGHs if there's no movement detected. The problem is the loop will get delayed if I put it inline. My code: (Don't mind my code, I'm pretty newbie)

int calibrationTime = 30;
int pirPin = 5;
int ledPin = 6;
int sensorState;
int stateCount = 0; //How much movement is detected
int stateThreshold = 3; //THRESHOLD
bool isSensorHigh;

void setup() {
  Serial.begin(9600);
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  digitalWrite(pirPin, LOW);
  Serial.print("calibrating sensor ");
  for (calibrationTime; calibrationTime > 0; calibrationTime--) {
    Serial.print(calibrationTime);
    delay(1000);
  }
  Serial.println(" done");
  Serial.println("SENSOR ACTIVE");
  delay(50);
}
void loop() {
  sensorState = digitalRead(pirPin);
  //Serial.println(sensorState);
  if (sensorState == 1) {
    isSensorHigh = true;
  }
  if (sensorState == 0 && isSensorHigh == true) {
    isSensorHigh = false;
    stateCount++;
  }
  //Set pins 2,3,4 here to LOW if there's no movement detected over time
  if (stateThreshold == 3) {
    switch (stateCount) {
      case 1:
        digitalWrite(2, HIGH);
        break;
      case 2:
        digitalWrite(3, HIGH);
        break;
      case 3:
        digitalWrite(4, HIGH);
        break;
    }
  }
  if (stateCount == stateThreshold) {
    blinkLeds();
    delay(3000);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(ledPin, LOW);
    stateCount = 0;
  }
  Serial.println(stateCount);
  delay(150);
}

void blinkLeds() {
  for (int x = 4; x > 0; x--) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(1000);
  }
}


texts: so I'm trying to creat a quadricopter with an arduino and gyroscope mp6050 and this with PID algorithme (using arduino PID,mpu library) so I make everything work separately but when it comes to use PID I don't know how to do it which one will be the input or setput ... I'm confused on how I can use gyroscope information and brushless information and other information to make my quadri fly ... thank you


texts:
I am making a circuit without using a PCB or perfboard and i am unsure if i am running the ground wire correctly.

I usually prototype on a breadboard with the ground all joining on the far right, is this the same concept? I wanted to know if this is the accepted  convention for running the ground back to the board.


texts:
I am wanting to POST some data from Arduino to WebService (written in .NET), intending to save some temperature data to MS SQL Server.

My code in arduino is:

void PostarDados(String dados, String chamador) {
  if (client.connect("mysite.com.br",80)) {
    client.println(chamador);
    client.println(F("Host: mysite.com.br"));
    client.println(F("Content-Type: application/x-www-form-urlencoded"));
    client.print(F("Content-Length: "));
    client.println(dados.length());
    client.println();
    client.println(dados);
  }
  if (client.connected()) client.stop();
}

When sending to Serial instead of client, I am obtaining the following text:

POST /webservice.asmx/SetValoresTempUmidade HTTP/1.1
Host: mysite.com.br
Content-Type: application/x-www-form-urlencoded
Content-Length: 39

Chave=1&Temperatura=23.30&Umidade=42.20

I have enabled HTTP POST in web.config to make HTTP POST possible (I can successfully invoke webservice from browser):

  <location path="Webservice.asmx">
    <system.web>
      <webServices>
        <protocols>
          <add name="HttpGet"/>
          <add name="HttpPost"/>
        </protocols>
      </webServices>
    </system.web>
  </location>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

I have also set ScriptMethod to my webservice functions:

<WebMethod()> <ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)>
Public Sub SetValoresTempUmidade(Chave As Integer, ByVal Temperatura As Double, ByVal Umidade As Double)
    Dim ctx As New DataClassesDataContext
    Try
        Dim A As New TBL_DADO
        A.CHAVE_INICIO = Chave
        A.DATA = Now
        A.TEMPERATURA = Temperatura
        A.UMIDADE = Umidade
        ctx.TBL_DADOs.InsertOnSubmit(A)
        ctx.SubmitChanges()
    Catch ex As Exception
    End Try
End Sub

Finally, I am trying to get some response from server using the following code (not receiving anything):

while (client.connected()) {
  while (client.available()) {
   buffer[counter++] = client.read();
  }
}

Explained that, I have two questions:

What am I doing wrong?
How could I debug this?


texts:
I am new so please be nice :)
I am trying to upload the Blinky example to my Arduino Nano BLE 33 but I get this error message from the Arduino IDE:
No device found on ttyACM0
Set binary mode
Send auto-baud
An error occurred while uploading the sketch
Set binary mode

Any idea what I could try?
I am running the Arduino IDE as superuser in Manjaro (latest versions of everything). If you need any more information please feel free to ask.
Full IDE output:
Sketch uses 77820 bytes (7%) of program storage space. Maximum is 983040 bytes.
Global variables use 42192 bytes (16%) of dynamic memory, leaving 219952 bytes for local variables. Maximum is 262144 bytes.
Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
Uploading using selected port: /dev/ttyACM0
/root/.arduino15/packages/arduino/tools/bossac/1.9.1-arduino1/bossac -d --port=ttyACM0 -U -i -e -w /tmp/arduino_build_408944/Blink.ino.bin -R
No device found on ttyACM0
Set binary mode
Send auto-baud
An error occurred while uploading the sketch
Set binary mode


texts: project not working when switching to battery power

texts:
I have a project which involves a photocell, an led, a push button, and a small hobby servo (tower pro sg5010) - the project works as expected when the arduino is powered by usb, but when I switch to battery power (4 AA batteries) - it doesn't work.

When powered by batteries, the servo actually starts right up and moves to the correct angle, so I feel like it should be getting enough power, but when I push the push button, it doesn't move to the new angle. I can hear a clicking noise of the servo on a regular interval, like a clock, and my LED flickers on and off at about the same interval.

If I'm doing something wrong, can anyone point it out? If it's just that the servo is not getting enough power, is there a way to add a transistor or something so that I don't have to add a separate power supply for the servo (I'm not sure there's room in my project's enclosure).

I've attached a fritzing diagram as well as my project code.

CODE:

#include <Servo.h>

const int buttonPin = 2;     // the number of the pushbutton pin
boolean buttonPushed = false;

const int ledPin =  13;      // the number of the LED pin

const int servoPin = 9;
Servo servo;
int angle = 0;
int servoStartAngle = 90;
int servoEndAngle = 10;

boolean servoActivated = false;

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

int photoCellPin = 2;
int photoCellThreshold = 500;
int photoCellActivated = false;

void setup() {
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);

  servo.attach(servoPin);
  servo.write(servoStartAngle);

}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  int photoCellVal = analogRead(photoCellPin);

  if (photoCellVal > photoCellThreshold){
   photoCellActivated = true;
  } else {
   photoCellActivated = false;
  }

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == LOW && buttonPushed == false) {
    // turn LED on:
    buttonPushed = true;
    Serial.println("button pushed");
  } else if (buttonState == LOW && buttonPushed == true){
   buttonPushed = false;
   Serial.println('deactivate');
  }

  if (buttonPushed == true){
   digitalWrite(ledPin, HIGH);
  } else {
   digitalWrite(ledPin, LOW);
  }

  if (buttonPushed && servoActivated == false && photoCellActivated == true){
    servoActivated = true;
    Serial.println("activate motor");

    for(angle = servoStartAngle; angle > servoEndAngle; angle--){
      servo.write(angle);
      Serial.println(angle);
      delay(15);
    }
  } else if (buttonPushed == false && servoActivated == true){ //deactivate
    for(angle = servoEndAngle; angle < servoStartAngle; angle++){
      servo.write(angle);
      Serial.println(angle);
      delay(15);
    }
    delay(200);
    servoActivated = false;

  }

  delay(200);
}


texts: Use HC05 and FTDI as Slave to Connect to control PC using HC05

texts:
Hi i just wanna ask if its possible to do this on HC05. So i can send some keyboard function?

and if yes can you tell me how. Thanks


texts:
I am trying to convert a char[12] array that contains a Mac Address into a byte[6] in order to use within the Ethernet.begin method. I have tried various methods from online, but had little success to date. The char array currently contains "A4BDC334688C" and i would like a byte array containing { A4, BD, C3, etc }.

The following is extremely close to working, with the output of the following
"File Opened.
A4BDC334688C
A4
9D
C3
34
68
6C" With BD incorecctly converting to 9D, and 8C becomming 68.

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

byte ByteMacAddress[6]; // RESERVED MAC ADDRESS
StaticJsonDocument<200> doc;

int ShotCount = 0;
byte buf[40];

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

  //Initialise SD Card for Config
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
  }

  // open the file for reading:
  File ConfigFile = SD.open("Config.txt");
  if (ConfigFile) {
    Serial.println("File Opened.");
  } else {
    Serial.println("error opening Config.txt");
  }

  //Deserialize Json Config in File
  delay(5);
  DeserializationError error = deserializeJson(doc, ConfigFile);
  ConfigFile.close();
  // Test if parsing succeeds.
  if (error) {
    Serial.print(F("deserializeJson() failed: "));
    Serial.println(error.c_str());
    return;
  }

  char* SDMacAddress = doc["MacAddress"];
  Serial.println(SDMacAddress);

  char arr[12];
  strcpy(arr, SDMacAddress);

  auto getNum = [](char c){ return c > '9' ? c - 'a' + 10 : c - '0'; };
  byte *ptr = ByteMacAddress;

  for(char *idx = arr ; *idx ; ++idx, ++ptr ){
    *ptr = (getNum( *idx++ ) << 4) + getNum( *idx );
  }

  //Check converted byte values.
  for( byte b : ByteMacAddress )
    Serial.println( b, HEX );
}

void loop(){
  //Maintain DHCP Lease
  //Ethernet.maintain();

  //GetShotCount();
  delay(500);
}


texts: Slowly decreasing the speed on a steppermotor over time

texts:
I am currently working on an elevator for my examsproject in school.
It's a quite simple simulation of a lifesize elevator.
I'm currently using a steppermotor for the elevatorchair and it's set with a certain speed.

However, in a real elevator, the speed would slowly decrease as it's progressing towards it's destination for a more pleasant ride for the passengers. I'd like to make the same simulation.
I was thinking of using the millis to periodically increase the delays over time, but I don't know whether alternative methods could be used for better results.


texts:
Arduino: 1.8.11 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"
Multiple libraries were found for "WiFi.h"
 Used: C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
 Not used: C:\Program
 In file included from C:\Users\User\Documents\Arduino\libraries\async-mqtt-client-master\src/AsyncMqttClient.h:4:0,
             from C:\Users\User\Desktop\sketch_jul13a\sketch_jul13a.ino:3:

C:\Users\User\Documents\Arduino\libraries\async-mqtt-client-master\src/AsyncMqttClient.hpp:9:22: fatal error: AsyncTCP.h: No such file or directory

compilation terminated.

exit status 1
Error compiling for board ESP32 Dev Module.

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


texts:
I wrote an code on Arduino and I getting compilation errors. I am using Arduino Due . I wrote the following code :

void setup() {
  Serial.begin(9600);
  analogWriteResolution(12);  // set the analog output resolution to 12 bit (4096 levels)
  analogReadResolution(12);   // set the analog input resolution to 12 bit

}

void loop() {

  // code
}

But compiler gave me the following errors :

'analogReadResolution’ was not declared in this scope
‘analogWriteResolution’ was not declared in this scope
‘DAC0’ was not declared in this scope

I'm using Arduino 2:1.0.5 (on Linux). The board list doesn't show Arduino Due (USB programmable).And I don't have Board Manager option. How do I install Arduino SAM Board to compile the program ?


texts: trying to connect to WiFi on ESP32 using credentials from SD card

texts: Am trying to connect to Wi-Fi on an ESP32 using credentials i stored on an sd card, am able to read and parse the credential and printing it to the serial monitor shows that the ssid and password is correct but not connecting to Wi-Fi, when i hardcode the Wi-Fi credentials it works what could i be doing wrong


texts:
Trainset info,

Turnout 1 = relay 1 - makes turnout track go left
          = relay 2 - makes turnout track go right
Turnout 2 = relay 3 - makes turnout track go left
          = relay 4 - makes turnout track go right
 Signal 1 = relay 5 - makes signal go green - train 1 starts driving
          = relay 6 - makes signal go red - train 1 stops for signal
 Signal 2 = relay 7 - makes signal go green - train 2 starts driving
          = relay 8 - makes signal go red - train 2 stops for signal

I have a arduino - uno and a 8 relay board.
I want to run a program (loop) for 1/2 hour / 1800 seconds.
Switching time should be 2 seconds (relay ON)

Can somebody help me with a millis code please.

Loop times should be:

relay 1 = (2),1250,(2),546 - total 1800 seconds
relay 2 = 620,(2),630,(2),546 - total 1800 seconds
relay 3 = 10,(2)1260,(2),526 - total 1800 seconds
relay 4 = 630,(2),640,(2),512 - total time 1800 seconds
relay 5 = 20,(2),1270,(2),505 - total time 1800 seconds
relay 6 = 600,(2),750,(2),446 - total time 1800 seconds
relay 7 = 640,(2),640,(2),516 - total time 1800 seconds
relay 8 = 1240,(2),450,(2),106 - total time 1800 seconds

Regards, Martinus van Walsum
xxxxxxxx@xxxxxxxx.com


texts:
I try to upload simple code (e.g. blink.ino) to my ESP8266-12 (I have the WeMos D1 breakout board). Until now, that worked without a problem: I had to pull GPIO0 down and then I could upload the compiled sketch.

Since today that does not work any more - but I did not change anything.

I get:

  error: espcomm_upload_mem failed

(I know that here are some questions / github issues out there that have the same error, but that was often because GPIO0 wasn't pulled down and the ESP was therefore not in FLASH mode.)

My config is: ESP8266, 80MHz, DIO, 115200, 512K (64K SPIFFS), ck, Serial

When I reset my board, having GPIO0 pulled down, the ESP sends this serial info:

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

The whole debug output is:

esptool v0.4.9 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
    setting board to ck
    setting baudrate from 115200 to 115200
    setting port from COM1 to COM6
    setting address from 0x00000000 to 0x00000000
    espcomm_upload_file
    espcomm_upload_mem
    setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
    espcomm_send_command: receiving 2 bytes of data
Uploading 228624 bytes from D:\Users\myusr\AppData\Local\Temp\build9c9ef3bdfe2fccb480bc6e4bac749e41.tmp/Blink.ino.bin to flash at 0x00000000
    erasing flash
    size: 037d10 address: 000000
    first_sector_index: 0
    total_sector_count: 56
    head_sector_count: 16
    adjusted_sector_count: 40
    erase_size: 028000
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    setting serial port timeouts to 15000 ms
    read 0, requested 1
    setting serial port timeouts to 1000 ms
warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed
closing bootloader
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
error: espcomm_upload_mem failed


texts: Using MULTIPLE shields on Arduino Uno R3

texts:
I'm very new to using Arduino!  I'll be using Ocean Controls KTA 259 thermocouple multiplexing shield AND a Sparkfun microSD shield on my UNO--to log temperature data for a study I'm doing.  The KTA 259 has a library and the integral SD library should work for the SD shield.
Q1:  I believe they physically connect no problem, but how can I be sure there are no pin conflicts, disastrous or otherwise?  In other words--what conditions MUST I avoid using shields and multiple shields?
Q2:  Can (or must) a single data pin be used by both shields, eg from thermo as output to SD as input, or does Arduino juggle all that?
Q3:  Can (or must) a single function, eg CS, be mapped onto the same pin on BOTH shields, or do they have to be separate allowing Arduino to handle that?
Thank you; I appreciate the help!


texts: How to connect a SilentStepStick TMC2130 stepper driver?

texts:
please excuse the noob question

Am connecting a SilentStepStick to arduino with a stepper, for bench testing.

It requires 5V power, plus I have a 24V power supply for the steppers.
+5V connected to Vio, and +24V connection to VM.

Question: how to connect the grounds?  The device has two GND pins.  Should I just connect one ground, from the 5V power supply, to avoid ground loops?

Or should grounds from both power supplies be connected?

Thankyou for any advice.


texts: Using MCP23017 with 5 rotary encoders, WITHOUT missing a single step from any of them?

texts:
I have recently followed the instructions in the answer to this question:
Reading several rotary encoders
posted by maximilian-gerhardt
I've wired everything up, and am using the interrupts example that can be found here:
https://github.com/maxgerhardt/rotary-encoder-over-mcp23017/tree/master/examples/Interrupt
Everything seems to work as expected, except that my assumption was that since this was an interrupt-based solution, that I wouldn't be missing any steps of any of the encoders. There are a total of 5 that will move at the same time, and it is clear that while it almost works, there are many steps that are missed.
I'm guessing that is because while one interrupt is being handled, all other interrupts are disabled?
Is there any way where I can ensure that every single motion (step CW or CCW) is registered on all 5 encoders?
Thanks!
Brian


texts: How to read/write variables persistenly on Arduino Due (no EEPROM/shield)?

texts:
I am relatively new to Arduino and I am currently writing some code to control a relay board. The on/off times are provided by the user at run-time and should be stored persistently (EEPROM or flash) in case of power-down.

On my Uno I worked with the EEPROMex library and that worked well. Now I have a Due which doesnt have any EEPROM and I am struggling how to store variables persistently. Specifically, I dont know how to access whatever I wrote to the flash memory previously. In the example below the content of test[] is obviously overwritten on every restart.

PROGMEM int test[] = {1, 2, 3, 123, 23};

void test()
{
  Serial.println((long)test);
  for (int i = 0; i < 5; i++)
  {
    Serial.println(test[i]++);
  }
}

I noticed that the address does not change during re-starts, so I I tried reading/writing beyond index 4. This out-of-bounds read/write worked, I guess since I am anyway not storing anything else. Interestingly even this memory which is out of the array is overwritten on power-up.

So: How do I store on unser input data (variables) persistenly on an Arduino due without using any shields?


texts:
I'm working with a load cell and HX711. There was no weight on the sensor but I kept getting strange values, I thought it was broken or something so I used my second load cell but the same thing happened again.
I'm wondering what is wrong with it ?
If anyone have worked with it or have an idea how to work with it, please don't hesitate to give your opinions.

 #include "HX711.h"
#include <Wire.h>

#define DOUT  A0
#define CLK   A1

#define DEC_POINT  2
#define STABLE  1

float offset=0;
float calibration_factor = 1;
//float real_weight = 1.560;//kg
float real_weight = 0.5;//kg

HX711 scale(DOUT, CLK);

unsigned char state=0;
long  FindZeroFactor();
float get_units_kg();
void  ReadWeight();
void  FindCalibrationFactor();

void setup()
{
  Serial.begin(115200);
  Serial.println();
  Serial.println("Auto Calibrate Program");
  Serial.println("Send 'a' to Find Zero Factor (Please Remove all weight from scale)");
  Serial.println("Send 'b' to Find Calibration Factor (Please insert know the weight on the scales)");
  Serial.println("Send 'c' Show weight on the scales");
}
void loop()
{
  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp=='a')
      state=1;
    if(temp=='b')
      state=2;
    if(temp=='c')
      state=3;
  }

  switch(state)
  {
    case 0:
    break;
    case 1:
      FindZeroFactor();
   //   ReadWeight();
      state=0;
    break;
    case 2:
     FindCalibrationFactor();
     state=0;
    break;
    case 3:
      ReadWeight();
      delay(200);
    break;
    case 4:

    break;

  }
}

long FindZeroFactor()
{
     Serial.println("Find Zero Factor");
     Serial.println("Please wait .....");
     scale.set_scale();
     scale.tare();
     long zero_factor = scale.read_average(20);
     Serial.print("Zero factor: ");
     Serial.println(zero_factor);
     return(zero_factor);
}

void FindCalibrationFactor()
{
  unsigned char flag_stable=0;
  unsigned int decpoint=1;
  for(unsigned char i=0;i<DEC_POINT+1;i++ )
    decpoint = decpoint*10;
  while(1)
  {
      scale.set_scale(calibration_factor); //Adjust to this calibration factor
      Serial.print("Reading: ");
      float read_weight = get_units_kg();
      String data = String(read_weight, DEC_POINT);
      Serial.print(data);
      Serial.print(" kg");
      Serial.print(" calibration_factor: ");
      Serial.print(calibration_factor);
      Serial.println();
      long r_weight      = (real_weight*decpoint);
      long int_read_weight = read_weight*decpoint;
      Serial.print(r_weight);
      Serial.print(" , ");
      Serial.println(int_read_weight);
      long x;
      if(r_weight == int_read_weight)
      {
        flag_stable++;
        if(flag_stable>=STABLE)
        {
          Serial.print("Calibration Factor is = ");
          Serial.println(calibration_factor);
          break;
         }
        }
       if(r_weight > int_read_weight)
          {
            x = r_weight - int_read_weight;
            if(x > 100)
              calibration_factor -= 1000;
            else if(x > 100)
              calibration_factor -= 10;
            else
              calibration_factor -= 1;
            flag_stable=0;
          }
          if(r_weight < int_read_weight)
          {
            x =  int_read_weight-r_weight;
            if(x > 100)
              calibration_factor += 1000;
            else if(x > 10)
              calibration_factor += 10;
            else
              calibration_factor += 1;
            flag_stable=0;
           }
  }
}

float get_units_kg()
{
  return(scale.get_units()*0.453592);
}
void ReadWeight()
{
  scale.set_scale(calibration_factor); //Adjust to this calibration factor
  Serial.print("Reading: ");
  String data = String(get_units_kg()+offset, DEC_POINT);
  Serial.print(data);
  Serial.println(" kg");
}


texts: RGBW LED strip: which components are required?

texts:
I'm brand new to this community, and in electronics as well.

I'm a software developer and I want to start a new journey with a project in mind: I want to control a 5 meters addressable LED strip for my living-room.

I need all the components for this project... I already know eclipse and Java world, but I need help in choosing the components for the project:

which Arduino (starter package maybe?)
LED strip (smd 5050 on sw2812b, sk6812, APA104...) more than 60 LEDs/m
Power Supply for the project

Can you point me to the right direction, posts that can be useful to me, so I can start on good basis?


texts:
I want the Parent class to pass a pointer to a callback function to the child class when the child class is created. I got this working when the parent was the sketch thanks to this post:
In this example, the parent was the .ino file, i.e. not a class but a collection of functions. This code worked fine.
However, I need to be able to make the call to the child constructor from a within a class as shown in the code below. I get I get an "invalid use of non-static member function on the line child = new Child ( handlerDispatcher );

Here is the complete code:

class Child {
public:
    typedef void ( *callback_t ) ( uint8_t, uint8_t );

    callback_t callback;

    //  Constructor
    Child ( callback_t _callback ): callback ( _callback ) {}

    void doCallback ( uint8_t id, uint8_t index ) {
        callback ( id, index );
    }

    void makeCallbacks () {
        doCallback ( 1, 0 );
        doCallback ( 2, 1 );
        doCallback ( 3, 2 );
    }
};

class Parent {
public:
    Child *child;

    Parent () {}

    void handlerDispatcher ( uint8_t id, uint8_t index ) {
        ( this->*callbackHandlers [ index ] ) ( id );
    }

    typedef void ( Parent:: *handlerPointer ) ( uint8_t );
    handlerPointer callbackHandlers [ 3 ] = {
        &Parent::handler1,
        &Parent::handler2,
        &Parent::handler3,
    };

    void handler1 ( uint8_t index ) { echo ( index ); }
    void handler2 ( uint8_t index ) { echo ( index ); }
    void handler3 ( uint8_t index ) { echo ( index ); }
    void echo ( uint8_t value ) {
        Serial.print ( "Got: " );
        Serial.println ( value );
    }

    void configure () {
        child = new Child ( handlerDispatcher );

    }
    void test () {
        child->makeCallbacks ();
    }
};

Parent parent;
void setup () {
    Serial.begin ( 115200 );
    parent.configure ();
    parent.test ();
}

void loop() {}


texts: Reading multiple NTC temperature sensors with Arduino

texts:
Hej..I am building a project with four NTC 10k ohm temperature sensor with Arduino. It is easy to measure only one NTC temperature sensor. There  is many examples for NTC measurement for example code written with Steinhart-Hart Equation or reading  ADC Thermistor with Lookup Table.

I found one example with Steinhart-Hart Formula.  I am not so good at coding  with Arduino but I Manage and build to write code for only one NTC sensor and read it with Nokia LCD 5110.  The question is how to do code for Multiple NTC sensors?

/* NTC temperature mesurment 13-08-2017
 *
 *  Using Nokia LCD 5110
 */

#include "LCD5110_Graph.h"
LCD5110 myGLCD(8, 9, 10, 12, 11);  // Setup Nokia 5110 Screen SCLK/CLK=5, DIN/MOSI/DATA=6, DC/CS=7, RST=8 Chip Select/CE/SCE=9,
extern uint8_t SmallFont[];
extern uint8_t MediumNumbers[];

int tempPin = 0;   // A0 analog input
int Vout, charTc ;
float R1 = 10000; //otpornost na sobnoj temperaturi 10K ili 10000 oma
float R2, Tk, Tc;
float Ac = 1.009249522e-03, Bc = 2.378405444e-04, Cc = 2.019202697e-07;
char charBuffer[10];

void setup(){
myGLCD.InitLCD(); //initialize LCD with default contrast of 70
myGLCD.setContrast(68);
myGLCD.setFont(SmallFont); // Set default font size. tinyFont 4x6, smallFont 6x8, mediumNumber 12x16, bigNumbers 14x24
myGLCD.clrScr();

myGLCD.print("Temp test",CENTER,0);
myGLCD.print("Check",CENTER,12);
myGLCD.print("Please Wait",CENTER,24);

myGLCD.update();
delay(5000);
myGLCD.clrScr();
}

void loop() {
  Vout = analogRead(tempPin);
  R2 = R1 * (1023.0 / (float)Vout - 1.0); // konvertovanje iz analogne u digitalnu
  Tk = (1.0 / (Ac + Bc*log(R2) + Cc*log(R2)*log(R2)*log(R2))); // Temperature in Klven
  Tc = Tk - 273.15; //temperature converted to celcious

charTc=dtostrf(Tc, 3, 2, charBuffer);

  myGLCD.clrScr();
  //myGLCD.print("Discharging",CENTER,0);
  //myGLCD.print("Temperature:",CENTER,0);
  myGLCD.print("Temp1:",0,0);
  //myGLCD.print( charTc,CENTER,20 );
  myGLCD.print( charTc,36,0 );
  myGLCD.print("Temp2:",0,10);
  myGLCD.print("Temp3:",0,20);
  myGLCD.print("Temp4:",0,30);
  myGLCD.update();
  delay(2000);
  myGLCD.clrScr();
}


texts: How to use voltage divider between ESP8266 (3.3v) and IR proximity sensor (5V)?

texts:
I am a software developer and I don't know much about circuits so I need help.

I have an ESP8266 (esp-12) 3.3V and I'm planning to use it with an IR proximity sensor (runs between 4.5-5V). I have 2 AA batteries (3V total) and 4 AA (6V total) power supplies. Also, I have a bunch of 10K Ohm and 330 Ohm resistors.

How can I use a voltage divider to supply sufficient voltage to these components, based on what I have? If it would help, I have a 100uF capacitor and I use a CP2102 to TTL Serial Converter to program. Any help will be appreciated. Thank you in advance.


texts: NodeMCU ESP8266 disconnected from WiFi after several hours running

texts:
I tried to test NodeMCU ESP8266 with this code from here

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

                /* Set these to your desired credentials. */
                const char *ssid = "dummy";  //ENTER YOUR WIFI SETTINGS
                const char *password = "12345678";

                //Web/Server address to read/write from
                const char *host = "192.168.43.128";   //https://circuits4you.com website or IP address of server

                //=======================================================================
                //                    Power on setup
                //=======================================================================

                void setup() {
                  delay(1000);
                  Serial.begin(115200);
                  WiFi.mode(WIFI_OFF);        //Prevents reconnection issue (taking too long to connect)
                  delay(1000);
                  WiFi.setSleepMode(WIFI_NONE_SLEEP);
                  WiFi.mode(WIFI_STA);        //This line hides the viewing of ESP as wifi hotspot

                  WiFi.begin(ssid, password);     //Connect to your WiFi router
                  Serial.println("");

                  Serial.print("Connecting");
                  // Wait for connection
                  while (WiFi.status() != WL_CONNECTED) {
                    delay(500);
                    Serial.print(".");
                  }

                  //If connection successful show IP address in serial monitor
                  Serial.println("");
                  Serial.print("Connected to ");
                  Serial.println(ssid);
                  Serial.print("IP address: ");
                  Serial.println(WiFi.localIP());  //IP address assigned to your ESP
                }

                //=======================================================================
                //                    Main Program Loop
                //=======================================================================
                void loop() {
                  HTTPClient http;    //Declare object of class HTTPClient

                  String ADCData, station, postData;
                  int adcvalue=analogRead(A0);  //Read Analog value of LDR
                  ADCData = String(adcvalue);   //String to interger conversion
                  station = "A";

                  //Post Data
                  postData = "status=" + ADCData + "&station=" + station ;

                  http.begin("http://192.168.43.128/c4yforum/postdemo.php");              //Specify request destination
                  http.addHeader("Content-Type", "application/x-www-form-urlencoded");    //Specify content-type header

                  int httpCode = http.POST(postData);   //Send the request
                  String payload = http.getString();    //Get the response payload

                  Serial.println(httpCode);   //Print HTTP return code
                  Serial.println(payload);    //Print request response payload

                  http.end();  //Close connection

                  delay(5000);  //Post Data at every 5 seconds
                }

It was running well and posted data to Database after a few hours. Then It was disconnected from WiFi somehow . Of course I reset power supply again It's connected.

How should I do to fix with that code to reconnect WiFi right after that accident Or any other Solution  for that ? Thank you


texts: motor does not move without Serial.println

texts:
having strange behavior with motor shield and steppers. when i'm trying to make onestep, motor just makes some high-frequent noise, but when i add Serial.println for debugging, it moves as intended.

what is going on here?

here is an example:

#include AFMotor.h //dunno how to put angle brackets here

AF_Stepper lrM(48, 1);

void rightStep() {
  lrM.onestep(BACKWARD, INTERLEAVE);
}
void leftStep() {
  lrM.onestep(FORWARD, INTERLEAVE);
}

void setup() {
  Serial.begin(9600);
  Serial.println("ready");
}

void loop() {
  rightStep();
//Serial.println("right");
}


texts:
Anyways cutting to the chase I am pretty good at C++ as I have been doing it for over 6 months pretty much 1-2 hours each day and I am looking for cool things to use my knowledge on ,I have heard of the Arduino's but the problem is I don't know my arse from my elbow when it comes to electrical engineering and all that so I have a couple of questions.
1. Do I need to have a background in engineering to use an Arduino.
2. Is there any cheap alternatives to the quite costly starter kit.


texts:
I have this code which works :

String ErrorMsg;
.......
if(!UploadPacketError)
{
    ErrorMsg="OK";
}
else
{
   ErrorMsg="NOK";
}

String creates a dynamically allocated array which I want to avoid. I would prefer something like :

unsigned char ErrorMsg[5];
......
if(!UploadPacketError)
    {
        strcpy(ErroMsg,"OK",3); // +1 for the Null Termination ?
    }
    else
    {
       strcpy(ErroMsg,"NOK",4); // +1 for the Null Termination ?
    }

i.e. is there a way to dynamically assign a value to a fixed size character array ?

Cheers
Thomas


texts:
I started working on the Arduino UNO with GPS Ublox Neo 6m. I connect GPS with arduino based on the schematic diagram as well as the script. It didn't display any data in the serial monitor even though it blinks and one more I did outside the building. I don't know what is causing it not to display any data.
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

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

void loop(){
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0){
    gps.encode(ss.read());
    if (gps.location.isUpdated()){
      Serial.print("Latitude= ");
      Serial.print(gps.location.lat(), 6);
      Serial.print(" Longitude= ");
      Serial.println(gps.location.lng(), 6);
    }
  }
}


texts:
A TMP35/36/37 is giving very high voltage readings, which results in high temperature readings. The serial monitor looks like this:

As you can see, the sensor value is in the 900s, voltage is almost 5, and temp is in the 400s. The circuit is very simple, just a TMP connected to 5V and ground and pin A0. Here is my code:

const int sensorPin = A0;
const float baselineTemp = 20.0;

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

}

void loop() {
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor value: ");
  Serial.print(sensorVal);

  float voltage = (sensorVal / 1024.0) * 5.0;
  Serial.print(", volts: ");
  Serial.print(voltage);

  Serial.print(", degrees C: ");
  float temperature = (voltage - .5) * 100;
  Serial.println(temperature);
  delay(1000);
}

This is a very simple program and a very simple circuit, so I'm not sure what is going on. Maybe the problem is the sensor itself. I have also tried this sensor with multiple other circuits and programs and the same thing happens.

If anyone knows anything about this, help would be great.


texts: Powering LED strips with two power banks and they randomly change different colors when i use the second power bank

texts:
So for one of my projects i want to power LED strips with power banks but once i try use the second power bank the LEDs half way through patterns jump to random different colors and then go back to the code im using to make sure they work, I dont think its a code issue as when i plug the power into my MEGA it works fine. I would use the MEGA to power the strips but i need 3 power sources to keep my strips at maximum brightness. would this be a voltage drop issue?

When I connected it to my 3 usb port power bank it works perfectly fine so it might be different currents causing it to jump im not to sure if im correct but its definitely something to do with using another power supply is causing my LEDs to randomly change multiple different colors randomly i just cant see if its a current or voltage issue. Any help would be greatly appreciated.

block diagram link


texts: Arduino/ESP8266 to put PC to sleep and wake it up

texts:
I have a Wemos D1 mini that's connected to a pc with usb, I want to be able to sleep the pc and wake it up programmatically.

Is there a way to do this? Like sending a simulated sleep keyboard button press?

Maybe I can send a wake up on lan command from the Wemos since they both are connected to the same router, but I'm still more interested in sending a sleep command.

I found this but it's old and it looks like they don't really have a way to do it.


texts: Using Arduino To Control Boot Sequence of PC

texts: I want to know if it is possible to use an arduino to tell a pc which os to boot to. I know It is possible to turn on the pc by wiring it to the motherboard pins with the power switch, and I know the arduino I have (http://www.amazon.com/SainSmart-ATmega328P-Development-Compatible-Arduino/dp/B00E5WJSHK/ref=sr_1_1?ie=UTF8&qid=1436368217&sr=8-1&keywords=sainsmart+uno+r3) can act as a mouse or keyboard. Can that be done before the pc has booted however?


texts: Op Amp Understanding + Holiday Lights Tutorial

texts:
I am following Jeremy Blum's tutorial for Holiday Lights: http://www.jeremyblum.com/2011/12/25/tutorial-14-for-arduino-holiday-lights-and-sounds

I am just trying to set up the circuit for one of the audio channels. I believe I followed the breadboard schematic. However, when I connect the Arduino the power, but without any audio input, the LED lights up. I would've thought that would not be the case.

Can someone help me correct my understanding here? Thanks.

Image of my breadboard: http://postimg.org/image/ibqfvezqp/


texts: Read float and long from external EEPROM chip

texts:
I am using an Arduino to read information from an EEPROM chip over I2C with the code I found here:
https://playground.arduino.cc/Code/I2CEEPROM

It works great for int and char values but I also need to read short, long, and float values.

They are stored in this order:  1510543923
is stored as: 01011010 00001001 00010010 00110011

How can I read multiple bytes into a single variable of these types?

I tried the following but it gives me a 16 bit number:

i2c_eeprom_read_buffer(0x50, 25, (byte *)bytes, 4);
long j = (bytes[3] << 0) + (bytes[2] << 8) + (bytes[1] << 16) + (bytes[0] << 24);


texts: RTC DS3231 Not resetting time on power loss

texts:
I'm completely removing power from a DS3231 RTC module and my call to rtc.lostPower() is never hit when I reconnect everything. I'm also removing the battery, I left it overnight and it remembers the time just before I disconnected everything, but doesn't register a power loss. I'm using this with a D1 mini.

void setup() {
  // put your setup code here, to run once:
  Serial.begin(baud);

  if (!rtc.begin()) {
    Serial.println("Couldn't find RTC.");
    while (1); // while true
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, resetting time.");
    ConnectWiFi();
    GetNtpTime();
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    Serial.println("Time set after power loss");
  }
}


texts:
let's suppose I have folder called AES, in this folder is file "AES.ino" where is code and folder "AESLib" what is library. In "AESLib" is file called "AESLib.h",

now when I try to include AESLib.h with

#include "AESLib/AESLib.h"

in my AES.ino, then Arduino command line tool complain that its not able to find "AESLib.h"

Where could be the catch?

Thanks


texts: Maintaining pull down on a relay with a shift register

texts:
I currently have an Arduino Mega project that uses a relay to switch some high voltage loads. Currently, I use a scheduler library so that every 250ms I check if certain conditions are met and if so I turn off or on the relay. The relay is active when pulled down.

I'm trying to figure out how to transition this project to using a shift register. If the pin needs to be pulled low to be turned on and I want to keep it on, how do I supply a steady "low" signal using a shift register if the register is clocked to only latch every 8 clock cycles (not to mention I only run this code every 250ms). Even if every bit that gets sent by the shift register is low, do I need to no longer use the scheduling library so that every time through the Arduino loop I am sending the low signal so that the low signal can remain constant? With the standard Arduino pin once I set it to low it stays low until I switch it to high. But with a shift register can I keep it low "until I switch it high?"


texts:
I am trying to communicate an industrial type counter using Modbus.
I have to calculate CRC16 value as two byte for send it.
I previously googled for few Arduino libraries and I get a same function as below. But, I couldn't understand the function well.

I need CRC as two bytes and as input I have 6 bytes.

Can someone explain the below function and what are the argument I need to provide.

uint16_t crc16_update(uint16_t crc, uint8_t a)
  {
    int i;
    crc ^= a;
    for (i = 0; i < 8; ++i)
  {
    if (crc & 1)crc = (crc >> 1) ^ 0xA001;
    else crc = (crc >> 1);
  }
    return crc;
 }


texts: Can I simply unplug the Arduino usb if serial communication is active?

texts:
So, after the sketch is uploaded, and I want to turn the Arduino off while it is running a sketch, all I have to do is unplug it.
Should be safe as long as nothing is uploading.
But I wonder, if I use serial communication between the Arduino and my Computer in a sketch, does it harm either if I simply unplug it?


texts: arduino atmega32u4 beetle extract hex code

texts:
I made a program using the Arduino Atmega32U4.

As a security issue, I tried to extract the hex code because I wanted to know if this program was duplicated.

avrdude -C"\avrdude.conf" -v -V -patmega32u4 -carduino -PCOM15 -b9600 -D -Uflash:w:C:\test\sketch_jun07b.ino.hex:i

This is what I executed in Command Line.

Avrdude ended with the following error: avrdude: stk500_getsync () attempt 1 of 10: not in sync:

Can you tell me if there is no risk of extracting and duplicating hex code from beetle or chipset unlike arduino board?


texts: Problem with a seven segment display. The segments blink then turn off

texts:
I can't figure it out what is the problem with my circuit, the segments turning on for sec and then they are turning off for good.

I tried to connect to GND instead of the 5 V but then, nothing happened.

My code:

void setup() {
  for (int pin = 2 ; pin < 9 ; pin++){ // setup pins 2 – 8 to be output
    pinMode(pin, OUTPUT);
  }

  for (int pin = 2 ; pin < 9 ; pin++){ // turn on pins 2 - 8
    digitalWrite(pin, HIGH);
  }
}

void loop(){}

Working simulation demo


texts: Will adding Ethernet shield reduce the IO count of Arduino?

texts:
I have searched this question but could not find an answer on this site.

There was a related question - Latest Ethernet shield - used pins, how to bypass restrictions on arduino forums, but, I was unable to understand what the answer meant.

The background of my project:

My project requires

| S.No. | IO Type | IO Qty |
|-------+---------+--------|
| 1     | AI      |     11 |
| 2     | DI      |      9 |
| 3     | DO      |     11 |

I intend to connect this arduino board via ethernet shield to a network. I want to receive data over the network for display and storage purposes on a PC.

Questions:

What Arduino board should I select?
Will ESP8266 be compatiable with the suggested model?
Are there any pitfalls that should be considered when making the
selection for this design.

P.S: I have raised the same question on the arduino forum. If I get an answer- I will share my answer here as well


texts: Can an Arduino emulate a USB mass storage device?

texts:
Question:

Can I connect an Arduino's USB port to the USB port of another embedded device that is expecting a USB thumb/flash device?

Or, can I connect a USB module to this embedded device, with the other end connected to GPIO's of the Arduino?

This embedded USB thumb device requires a thumb drive to transfer a file. I need to emulate the connection, disconnection, and thumb drive with the folder and file with a Arduino.

Is it possible to emulate an USB thumb drive between an Arduino and an embedded device's USB port?

Research:

I saw a couple other questions that talk about USB being a master/slave configuration and that certain IC are required. Additionally, that there were some cables that can be used for two-way data transfer (mostly for PC to PC data transfers). If that is the case, could one of those cables be used for this configuration? Which cable would work?

Possible Solution:

The embedded device I need to emulate a thumb drive on will automatically search for the file in a specific folder of the thumb drive. Would I be able to partition a section of an SD card with the SD card module to appear as a thumb drive, and then connect that partition to the embedded device via USB-A to USB-A cable?

Diagram:

Arduino USB Port -> USB Cable -> Embedded Device USB Port
Arduino GPIO -> USB Module -> USB Cable -> Embedded Device USB Port

Requirements:

Connection via USB cable between Arduino and an embedded device's USB port.
Ability to emulate the connection and disconnection of a USB thumb drive on the embedded device.


texts:
I am using an external 5 volt power supply to power my Sonar, and I am using a Teensy 3.1
to read in analog signal  from the sonar. my question is since the teensy is only 3.3v tolerant with analog in, is it safe to use with the maxbotix sonar?


texts: [SOLVED]SIM7600 Module Power up by Arduino Uno doesn't work

texts:
Am using SIM7600X 4G HAT with Arduino Uno
I follow to manual to Power up the module and it works well, The NET light flashing.

But when I connect to Arduino Uno and use DigitalPin 2 write (High -> Delay500ms -> Low) for "power on pulse" it doesn't work, The NET light still not flashing.

My code:
#include <Waveshare_SIM7600.h>
// Pin definition
int POWERKEY = 2;

char phone_number[] = "XXX";      //Store the phone number you want to call

void setup() {
  Serial.begin(9600);
  sim7600.PowerOn(POWERKEY);
  sim7600.PhoneCall(phone_number);
}

void loop() {

}

code from Waveshare (Waveshare_SIM7600.h):
/**************************Power on Sim7x00**************************/
void Sim7x00::PowerOn(int PowerKey = powerkey){
   uint8_t answer = 0;

  Serial.begin(9600);

  // checks if the module is started
  answer = sendATcommand("AT", "OK", 2000);
  if (answer == 0)
  {
    Serial.print("Starting up...\n");

    pinMode(PowerKey, OUTPUT);
    // power on pulse
    digitalWrite(PowerKey, HIGH);
    delay(500);
    digitalWrite(PowerKey, LOW);

    // Stuck in below loop because Send AT command and no response ///////
    // Becuase NET light not flashing (not connect) //////////////////////

    // waits for an answer from the module
    while (answer == 0) {     // Send AT every two seconds and wait for the answer
      answer = sendATcommand("AT", "OK", 2000);
      delay(1000);
    }

  }

  delay(5000);

  while ((sendATcommand("AT+CREG?", "+CREG: 0,1", 500) || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0)
    delay(500);
}


texts: What should the frequency reading of the SPI clock be with this code?

texts:
My Extech EX330 multimeter is reading 3.439Mhz on the pin 13 on my Arduino Uno running the following code. Is the reading correct? If the divider is 2, shouldn't I get 8 Mhz (16Mhz / 2)?

    #include <SPI.h>
void setup()
{
  pinMode(13, OUTPUT);

  digitalWrite(13, HIGH);
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV2);

}
void loop()
{

  byte pot = B0;
  SPI.transfer(pot);                        //  Do SPI transfer of variable pot
}


texts: Using an Arduino Nano to program (as ISP) a standalone 328p

texts:
I uploaded the ArduinoISP sketch to an Arduino Nano to use it as a programmer for other chips.

It worked successfully to program an ATtiny45, I did the usual wiring between them, and added a 10uF between RST and GND of the Nano. Everything worked.

Now I'd like to program a standalone ATmega328p with the Nano, I did the usual wiring as well (see this tutorial), as well as this 10uF cap.

But it does't work:

  avrdude: Device signature = 0x000000
  avrdude: Yikes!  Invalid device signature.
           Double check connections and try again, or use -F to override
           this check.

The reason might be because this 328p comes from an Arduino Uno, probably configured to be ext-clocked by a crystal. Whereas I don't have any crystal here and wanted to clock the 328p with the internal clock.

Question: how can I restore the 328p to factory default / internal clock, if I don't have a crystal?

Or what other reason can this error be?

Edit: a solution is found here: Change the fuses of an Arduino Uno (can an Arduino Uno change its own fuses?)


texts:
I have an LCD keypad shield that I'm using to control a Catalex serial MP3 module and I have an int variable that has the volume setting which can go from 1 to 30. I'm trying to send the variable to the module but it's not working. Here's the code for the serial request:
void SetAttractVolume() {
  SerialString = SerialString2 + AttractVolume;
  delay(20);
  Send_buf[0] = 0x7e; // starting byte
  Send_buf[1] = 0xff; // version
  Send_buf[2] = 0x06; // the number of bytes of the command without starting byte and ending byte
  Send_buf[3] = 0x06; //
  Send_buf[4] = 0x00; // 0x00 = no feedback, 0x01 = feedback
  Send_buf[5] = 0x00;
  Send_buf[6] = 0x12;
  Send_buf[7] = 0xef; //ending byte
  for (uint8_t i=0; i<8; i++) {
    mySerial.write(Send_buf[i]); // send bit to serial mp3
    Serial.print(Send_buf[i], HEX); // send bit to serial monitor in pc
  }
  Serial.println();
}

"0x12" is the volume control, you set the 12 to any number from 1 to 30 to change it, I thought I could just put my variable in there, like this:
void SetAttractVolume() {
  SerialString = SerialString2 + AttractVolume;
  delay(20);
  Send_buf[0] = 0x7e; // starting byte
  Send_buf[1] = 0xff; // version
  Send_buf[2] = 0x06; // the number of bytes of the command without starting byte and ending byte
  Send_buf[3] = 0x06; //
  Send_buf[4] = 0x00; // 0x00 = no feedback, 0x01 = feedback
  Send_buf[5] = 0x00;
  Send_buf[6] = 0xAttractVolume;
  Send_buf[7] = 0xef; //ending byte
  for (uint8_t i=0; i<8; i++) {
    mySerial.write(Send_buf[i]) ;//send bit to serial mp3
    Serial.print(Send_buf[i],HEX);//send bit to serial monitor in pc
  }
  Serial.println();
}

This doesn't compile, I know it's not the correct way to do it, but I want to know how to do it right.
Thanks in advance.


texts: unresolved overloaded function type for Wire.onReceive

texts:
I am attempting to make an I2C slave out of my Arduino and I can't get past the Wire.onReceive function. Here is my code. The documentation says to just add a function that has the style of void myHandler(int bytes) but I can't figure out why my readPI function does not meet these requirements.

    #include "piCom.h"
    #include "WireAddresses.h"
    #include <Wire.h>

    pi::pi(){
       Wire.begin(NB_INFO); // is 0x04
       Wire.onReceive( readPI );
       //Wire.onRequest(sendPI);
    }

    void pi::readPI(int byteCount){
       while( Wire.available() ){

             ref_IMU = Wire.read();

       }//end while

    }//end readPI

    void pi::sendPI(){

       Wire.write(1);
       //use to send pressure info to pi

    }//end sendPI

    //double pi::getref_IMU(){return ref_IMU;}

then here is the error

piCom.cpp: In constructor 'pi::pi()':
piCom.cpp:7: error: no matching function for call to'TwoWire::onReceive(<unresolved overloaded function type>)'
 Wire.onReceive( readPI );
                        ^

no matching function for call to 'TwoWire::onReceive(<unresolved overloaded function type>)'

Any help is greatly appreciated.


texts: Errors when compiling the GSM SMS receive example from the Arduino IDE

texts:
I want to receive SMS and check whether the character is 'y' or 'n'. If it is 'y', set a pin to high so that a light glows. I thought I could use the example code given in the Arduino IDE for receiving SMS, but when I compile (without connecting the board, using ctrl+r) it shows the following errors:

Arduino: 1.8.1 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from F:\Arduino\libraries\GSM\src/GSM.h:46:0,
                 from F:\Arduino\libraries\GSM\examples\ReceiveSMS\ReceiveSMS.ino:21:
F:\Arduino\libraries\GSM\src/GSM3ShieldV1BandManagement.h:49:125: warning: 'typedef' was ignored in this declaration
 typedef enum GSM3GSMBand {UNDEFINED, EGSM_MODE, DCS_MODE, PCS_MODE, EGSM_DCS_MODE, GSM850_PCS_MODE, GSM850_EGSM_DCS_PCS_MODE};
                                                                                ^
F:\Arduino\libraries\GSM\examples\ReceiveSMS\ReceiveSMS.ino: In function 'void setup()':
F:\Arduino\libraries\GSM\examples\ReceiveSMS\ReceiveSMS.ino:47:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
                                  ^
Sketch uses 13322 bytes (41%) of program storage space. Maximum is 32256 bytes.
Global variables use 996 bytes (48%) of dynamic memory, leaving 1052 bytes for local variables. Maximum is 2048 bytes.
An error occurred while uploading the sketch
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Please help me rectify the error.

I use a SIM900 GSM board. I connect the tx and rx of the GSM board to the Arduino's tx and rx.


texts: Is it necessary to reduce the size of libraries?

texts:
For example RTClib library have codes for DS1307, DS3231, PCF8523 and softRTC. but I'm only using DS3231 and don't need the extra codes there to occupy my Arduino flash memory.

Does Arduino IDE only "upload" those parts of libraries that is being used in the sketch or just uploads the whole library?


texts: How to stop transmission i2c on LCD 16x4 i2c

texts: i want to try to stop communicaton I2C between arduino and lcd I2C but i don't see any command to stop this communication. I try with Wire.endTransmission or Wire.end but the transmission to the LCD continue without problem. I'm using this library NewliquidCrystal and inside no command for end transmission. I need to interupt that communicaton for have a good management of lcd or if know a new library with best features. Thank's for help


texts: How to send data from Arduino Uno with SIM900 GPRS to Firebase

texts:
I'm creating a real-time vehicle tracking Android application using the Arduino Uno and SIM900 GPS. I want to use Firebase as the database for the coordinates which will hold just the longitude and latitude. My question is about sending the data through the GPRS to Firebase. Right now I've only been able to use a terminal program to send AT commands to create a connection but I've been getting errors when connecting to firebase using AT+CIPSEND. I know that it only excepts https traffic so I've been trying commands from here. Here is some code that I've tried:

AT
OK
AT+CREG?
+CREG: 0,1

OK
AT+CGATT?
+CGATT: 1

OK
AT+CIPSTATUS
OK

STATE: IP INITIAL
AT+CIPMUX=0
OK
AT+CSTT="att.mvno","",""
OK
AT+CIICR
OK
AT+CIPSTART="TCP","https://mygpstracker.firebaseio.com","80"
OK
CONNECT OK

and

AT+CIPSHUT
OK
AT+CIPSTART="TCP","https://mygpstracker.firebaseio.com","443"
OK
CONNECT OK

If I use CIPSEND, how should my message be formatted to send lat or long in a way Firebase can interpret?
Or am I going about this in a convoluted manner? Is there an easier way? I appreciate any help/comment. Thank you.


texts: A device that connects to 4g and send sms

texts: I want to know the best options for making a device that connects to my api and gets from it a phone number and a text and sends this text as sms to the phone number, meaning it uses the 4g or 3g network to connect to the api and then sends the message via sms.


texts: Sketch is not being received by Arduino even though Arduino Editor acts like it is finished?

texts: In my attached screen capture the Arduino Editor appears to be performing the upload, however it never finishes. Completes three steps, the last being the sketch up-load and then states that it is busy.  Sorry that I can't submit a short video. Please suggest ideas to solve this issue.  Maybe this is related to my first question?


texts: trying to switch input on my speakers via infrared using web browser but i have issue getting it working

texts:
ived tested the IR code with
https://github.com/wemos/D1_mini_Examples/blob/master/examples/04.Shields/IR_Controller_Shield/IRsend/IRsend.ino

and it works that way, but when i try to code it together with the web server, i get nothing, can someone explain to me what's wrong in my code? the webserver works fine, its the IR part i dont fully understand why its not working

#include <i18n.h>
#include "ESP8266WiFi.h"
#include "ESP8266WebServer.h"
#include <IRremoteESP8266.h>
#include <IRsend.h>
ESP8266WebServer server(80);

void setup() {
  Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
  WiFi.begin("net", "pass");  //Connect to the WiFi network

  while (WiFi.status() != WL_CONNECTED) {  //Wait for connection

    delay(500);
    Serial.println("Waiting to connect…");

  }

  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  //Print the local IP

  server.on("/on", []() {   //Define the handling function for the path

    server.send(200, "text / plain", "Switching to USB input");
    #define IR_LED D3
    IRsend irsend(IR_LED);  // Set the GPIO to be used to sending the message.
    uint16_t rawData[71] = {8992, 4494,  574, 558,  572, 558,  574, 558,  574, 558,  574, 558,  572, 558,  572, 556,  572, 1660,  572, 1658,  574, 1658,  574, 1658,  574, 1660,  574, 1660,  574, 1660,  574, 1658,  602, 528,  574, 558,  574, 1658,  576, 556,  574, 556,  574, 1660,  574, 556,  574, 554,  574, 554,  574, 1658,  574, 556,  574, 1656,  576, 1658,  576, 556,  574, 1658,  576, 1656,  576, 1658,  576, 39978,  8994, 2256,  578};
    irsend.begin();

  });

  server.on("/", handleRootPath);    //Associate the handler function to the path
  server.begin();                    //Start the server
  Serial.println("Server listening");

}

void loop() {

  server.handleClient();         //Handling of incoming requests

}

void handleRootPath() {            //Handler for the rooth path

  server.send(200, "text/plain", "NinjaLights");

}


texts: DS1307 RTC not working with CC3000 WiFi shield (I2C bus hangs)

texts: I am trying to use a DS1307 (from Sparkfun, BOB-12708) with an Arduino Leonardo. I have connected the SDA, SCL, GND, and 5V pins from the RTC to the Arduino. However, with a CC3000 WiFi shield on the Arduino, the I2C bus hangs. Specifically, Wire.endtransmission() hangs, called by rtc.isrunning(). I have confirmed that it works properly on the same Arduino without the WiFi shield. I am using the ds1307 RTClib example for testing it.


texts: I keep gettin the error " expecte ')' before ';'. Can someone please tell me what is wrong with my code?

texts:
int MyNumber;
String msg= "What is your favorite number? ";
String msg2= "Haha, Nice! ";
String msg3= " I SAID, WHAT IS YOUR FAVORITE NUMBER! ";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(msg);
  while (Serial.available()==0)
    for (MyNumber=Serial.parseInt(); (MyNumber==69); (Serial.println(msg2);)
    {
        Serial.println(msg3);
    }
}


texts: Voltage divider producing unexpected voltage

texts:
I'm trying to run a neopixel strip and an arduino from the same power supply using a voltage divider to get 5V to the strip.

Here are the values for my voltage divider:

R1 = 1500 Ω

R2 = 1000 Ω

Vin = 12 V

resulting in:

Vout = Vin*(R2/(R1+R2)) = 12*(1000/(1500+1000)) = 12*(1000/2500) = 12*0.4 = 4.8

When the divider is connected at its inputs but not at its outputs, I measure the expected 4.8V across R2. But as soon as I connect the neopixels, I only get about 1.6V.

Could anybody explain this || Suggest a possible solution?


texts:
Looking at the pinout for the Arduino MEGA:

I see that Pins 20 and 21 can be both SDA and SCL or Interrupts 0 and 1.

If I'm using an Adafruit I2C 16x2 RGB LCD Shield connected to the SDA and SCL pins by the USB Jack, is there anything I can do in my code to still use INT0 and INT1 off Pins 20 and 21 for a different purpose?


texts: What is happening in this basic push-button circuit?

texts:
In the example circuit below (Arduino Uno R3), what would the equation be to identify the amperage going into pin 2 when the button is pressed? What if I used the 3.3v on the arduino or a 9v battery instead?
What is happening to the input pin when the button is not being pressed? (I assume it's a guaranteed LOW state due to any current being sapped by the GND, yes?)
What would happen without the pull down resistor? A short when the button is pressed? What would happen without the ground being connected at all? Anything?
A tutorial for how to choose a pull down resistor I seen suggested a resistance value of 10 times the impedance of the pin. I'm not quite sure where to find this impedance value, but I have seen on an arduino tutorial "A 10K resistor is a good value for a pullup or pulldown resistor." Just not much of an explanation of why that value.
Sorry for so many little questions in this one question, but these are the kinds of things I'm not seeing addressed in most tutorials.


texts:
I need help I use Touch Sensor(T)v.0 and it always receives a signal not matter I touched it or not.
Here is the code.
#define TOUCH_PIN 7
int touchVal = 0;

void setup() {
   Serial.begin(115200);
   pinMode(TOUCH_PIN, INPUT);
}

void loop() {
   touchVal = digitalRead(TOUCH_PIN);
   Serial.println(touchVal);
   delay(200);
}


texts:
I am creating a PCB which is a modification of the Arduino on a breadboard. I am intending to buy an USB to Serial breakout from Adafruit so that I can upload my sketches to the atmega 328 I'll be using.

However, in order to reduce power consumption (later I want to run my circuit by using some AA batteries), I would like to turn off the USB to Serial breakout. I thought originally about adding a SPST switch to disconnect it when not using it, but I wonder if it is possible to power it from the USB (whenever I connect something) instead of having to connect its VCC header to the circuit's 5v power.

Is it possible to do that? Or is there any other way I to accomplish this that I'm not thinking of?

UPDATE: For clarity sake, I will explain my design choices: I want this circuit to power some peristaltic pumps that work on 12V. Thus, I'm providing 12V for the pumps and using a regulator to lower the voltage to the circuit. I don't see this is a huge problem for power consumption because the circuit will be in low-power 98% of the time, only waking up one minute per hour. Sometimes, it will run on batteries, which is the reason I wanna eliminate the USB-to-Serial. However, when connected to a power adaptor, I want the USB to be available.

All the best,

Francis


texts: Receiving Multiple data on Arduino Serial

texts:
I am writing a very simple code in Arduino Nano, in which I am reading data that I send on Serial. Here is the code snippet.

int incomingByte ;

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

void loop() {

    if (Serial.available() > 0) {

            incomingByte = Serial.read();

            Serial.print("I received: ");
            Serial.println(incomingByte);
    }

}

When I send 'A' , I receive the following output:

I received: 65

I received: 13

I received: 10

What is wrong with the working of Serial Port here?


texts:
I'm trying to make a cable checker to help me make custom cables for my computer. I'm thinking I plug the cable ends into sockets on the device, then the Arduino checks between different pins to make sure that no wires are in the wrong spot or unplugged.
So I'm thinking it runs through like this:
I plug the cable into connectors on the device. The Arduino has the PSU pinouts saved. Pin 1 represents one end of the cable, pin 2 represents the opposite end. Same with 3-4/5-6 etc. If the cable is assembled correctly, it should act as a connection between pins 1-2, pins 3-4, 5-6 etc.
tests pin 1 - 2 to see if they're connected, if yes, light up a green LED, if not, light up a red LED
tests pin 3 - 4, does the same thing
Repeats this  for every wire in the cable
Am I on the right track? How would I do this? I've seen people talking about pullup resistors but I'm also seeing people say that shorting can damage the board


texts:
What are the advantages of each language when using the Arduino?

I'm thinking this is a good general question, but I'll add a bit about why I'm asking if anyone wants to give me a tip.

I'm experienced in preprocessed languages like JavaScript, PHP, and have fiddled with languages like Java and Visual Basic. In other words I know programming techniques and both classical and prototypal object orientation, but nothing about communicating directly with hardware.

I'm making an octocopter, and am thinking that an object oriented approach will be the easiest. (The software will have very many features...) However I have never written in C++.

Since this is a Q&A site that's supposed to help others, only the general question presented at the beginning is of much importance, but I'd appreciate any comments on my situation.


texts: CC3000 - Send GET request to an app on heroku

texts:
I'm struggling to get the CC3000 to connect to a heroku hosted app, and other examples posted online haven't turned on the light bulb quite yet for me.

The gist is that I collect some temperature and humidity readings, and then send those via a GET request using the CC3000. The heroku app then reads the parameters and displays them on a page.

The CC3000 hardware is A-OK, as I've tested it using the test sketches. The sketch I've put together (on github: https://github.com/jsimms/compost_monitor) works except for the last bit where it needs to connect to the server and send the HTTP request. Which makes me wonder if this is a heroku quirk, or if I'm just screwing something up right at the finish line.

First, I define everything

#define WEBSITE      "myapp.herokuapp.com"
String route = "/sensor";
uint32_t ip;
int port = 80;

Then during setup, I use getHostByName to assign the ip variable. I print it out, just to confirm it was able to snag an ip. I then close it to make sure I don't screw up anything during the loop.

  ip = 0;
  Serial.print(WEBSITE); Serial.print(F(" -> "));
  while (ip == 0) {
    if (! cc3000.getHostByName(WEBSITE, &ip)) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  }

  cc3000.printIPdotsRev(ip);
  Serial.println("");

  // Close the connection
  Serial.println(F("Closing connection..."));
  cc3000.disconnect();
  Serial.println(F("Connection closed."));

During the loop, I create a String with the request, and then call a function that actually does the request.

String request = "GET " + route + "?temp=" + temperature + "&hum=" + humidity + " HTTP/1.0\r\n";
send_request(request);

Finally, the send_request function is supposed to take care of connecting via TCP and sending it.

void send_request (String request)
{
  // Connect to server
  Serial.println("Connecting to server...");
  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, port);

  // Send the request
  if (www.connected()) {
      www.println(request);
      www.println(F("User-agent: CompostMonitor/1.0\r\n"));
      www.println(F("\r\n"));
      Serial.println("Connected & data sent successfully...");
    }
    else {
      Serial.println(F("Connection failed."));
    }

    while (www.connected()) {
      while (www.available()) {

      // Read answer
      char c = www.read();
      Serial.println(c);
      }
    }

  // Disconnect
  Serial.println("Closing connection...");
  Serial.println("");
  www.close();
}

However, I never get anything but connection failed.

Any insight and help would be wonderfully appreciated. :)

UPDATE: Ok. So, through the comments below, I was able to identify by telnet'ing the web app, that there was something wrong with the HTTP requests. I made a small tweak to the app, but the real issue was that I wasn't including Host: weathervane.herokuapp.com in the header. FML! I'm going to test out sending the request with the Arduino later tonight. Hopefully that puts an end to this HTTP 101 lesson I've been doing.


texts: Problem with using pure C code to program default UART (UART0) in Arduino Mega

texts:
Can I code default serial port in Arduino Mega (USART0, I assume) in pure C? I mean to set up it and configure directly by ATmega's registers?

I'm asking because I'm trying to do it and I have a problem. Below is code which I use and Arduino doesn't transfer anything...

#include <avr/io.h>

#define F_CPU 16000000
#define BAUD_RATE 9600
#define MY_UBRR (F_CPU+BAUD_RATE*8UL)/(16UL*BAUD_RATE)-1

void setup() {

    UART_Init(MY_UBRR);
}

void loop() {
    UART_Transmit('a');

 }

void UART_Init(unsigned char ubrr)
{
   UBRR0H = (unsigned char)(ubrr >> 8);
   UBRR0L = (unsigned char)ubrr;
   UCSR0B = (1<<RXEN0) | (1<<TXEN0);
   UCSR0C = (1<<USBS0) | (1<<UCSZ00);
}

 void UART_Transmit(unsigned char data)
 {
    while(!(UCSR0A & (1<<UDRE0)))
    UDR0 = data;
 }

That code I created following the datasheet for ATmega 2560. It has been compiled and programmed but doesn't work at all...

Please give me any advice. It's important for me use just C code in that case.


texts:
How can i convert a String to IPAddress on arduino / esp ?

etc. "192.168.1.2"  -> IPAddress(192, 168, 1, 2)

Tried this

void setup() {

  Serial.begin(115200);

  IPAddress apip;

  const char *apipch;
  apipch = "192.168.4.1";

Serial.println(apip.fromString(apipch));

}

void loop() {
  // put your main code here, to run repeatedly:
}

But i just get an output "1"


texts:
Could one use the Arduino Due to control camera module like OV5642 and send the data to spi device? My project is to capture image with OV5642 and then to send the image data(RGB565) to other device via spi. For this STM32 must be enough, but I'd be happy if I can use the arduino IDE. Because it is much easier to program.

Could you please let me know, if you can use the Due for this task?


texts: Can I control a stepper motor with a sensor?

texts: Can I control a bipolar stepper motor with an L293d motor driver shield using HC-SRO4 ultrasonic distance sensor on arduino?


texts: Arduino hardwareSerial Bluetooth.println not sending string over 310 chars

texts:
Hey all I am wondering if my code below can be modified in order for the Arduino to send more than 300 chars to a HM-10 bluetooth 4.0 le module?

#include <SoftwareSerial.h>
#define SERIAL_BUFFER_SIZE 512

SoftwareSerial bluetooth(8,9); // RX, TX
String btString;
String comString;
int isVS;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {;}

  Serial.println("PC Side Connected");

  bluetooth.begin(115200);
  while (!bluetooth) {;}

  bluetooth.println("Bluetooth Side Connected");
}

void loop() {
  if (Serial.available() > 0) {
    //The IDE Sends and the phone receives
    comString = Serial.readString();

    //Check to see if this request is coming from Visual Studio
    isVS = comString.indexOf("_VS");

    if (isVS > -1) {
      //Is coming from Visual Studio so display it over serial port
    } else {
      //Not coming from VS so send it to the bluetooth phone
      //bluetooth.write(comString);
      bluetooth.println(comString);
    }
  }

  if (bluetooth.available() > 0) {
    //The phone sends and the IDE receives
    btString = bluetooth.readStringUntil('\n');
    Serial.println(btString);
  }
}

As in my code above, I've already tried to add the #define SERIAL_BUFFER_SIZE 512 to the top to give the software serial more buffers but that does not allow me to send more than ~310 chars.

So sending this string:

  {MAC:'00-14-22-01-23-45',settings:{rgb:true,quotes:true,sleep:false,timeFrame:{on:'05:30:00',off:'22:30:00'},reset:false,weatherZip:'57104',userInfo:{left:'John
  Rambo',right:'T100'}},wifiInfo:{Name:'ItBurnsWhenIP',Pwd:'AwHk6gKnsMdxw3boWWAhus5NNCV304YQb/2287QqzH0WnS5W59vCzzW2pR8kgHI79hAUglQOCcBiEKiNWRBQ3oyvyJ0/fDfM1aKa9gfoy3kGHA=='}}

works just fine but if i send out a little more information:

  {MAC:'00-14-22-01-23-45',settings:{rgb:true,quotes:true,sleep:false,timeFrame:{on:'05:30:00',off:'22:30:00'},reset:false,weatherZip:'57104',userInfo:{left:'JohnRambo',right:'T100'}},wifiInfo:{Name:'ItBurnsWhenIP',Pwd:'AwHk6gKnsMdxw3boWWAhus5NNCV304YQb/2287QqzH0WnS5W59vCzzW2pR8kgHI79hAUglQOCcBiEKiNWRBQ3oyvyJ0/fDfM1aKa9gfoy3kGHA==','testing
  out some more strings'}}

It shows everything but the gs'}} at the end on the iphone.

How would i go about fixing this so i can send much more than this?


texts: ESP8266 (Huzzah Feather) I2C scanner finds nothing

texts:
I am trying to address an I2C device on my Huzzah Feather (Adafruit) ESP8266, but the I2C scanner tool does not detect anything.  All is sufficiently powered and quadruple checked the wiring.

Is there something I am missing for this board in regards to I2C connections?

I've had no issue on an Arduino, which uses the 2 pins on the Analog rail for I2C...

The Huzzah has no Analogue But the one pin, regardless, Huzzah Feather has different (still pin 4 & 5 tho) I2C,  and not via A0 A1 like on the Uno.

Do I need to dig deep and change some pin configurations for the Huzzah?

Thought I would ask before wasting more time on trial and error experiments.

Update Note:

I failed to mention there is a Feather Neopixel board (4x32) hard soldered to the board. Which I suspect is not the culprit as this issue also persists on same board without the neopixel shield attached.

Update

The soldering job was good, but discovered a faulty wire.  This allowed the I2C scanner to detect the i2C controller (LCD2004) at the address of 0x3F...

I checked with a I2c LCD library example, and I don't get any characters to come up... This is the same with both Huzzah Feather boards, one with Neopixel shield and the other is bare.


texts: I am working on a thermometer and humidity why am i getting this error

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

In file included from C:\Users\Admin\Documents\Arduino\libraries\DHT-sensor-library-master\DHT_U.cpp:15:0:

C:\Users\Admin\Documents\Arduino\libraries\DHT-sensor-library-master\DHT_U.h:36:29: fatal error: Adafruit_Sensor.h: No such file or directory

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

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


texts: NodeMCU V3 usb not working, kills every usb connection

texts:
I'm new to all this IOT thing.  I just received a NodeMCU V3.  I tried to plug it into my pc using the usb port, but when I do this, every usb devices disconnect from Windows (Keyboard, mouse, etc.).  They connect back when I disconnect the NodeMCU.  I downloaded the CH340G driver and it still doesn't work.
I tried to connect it with USB to Serial converter, but it still doesn't work, either on 3.3V or 5V.   I have a 5V and 3.3V volt output on my USB to serial device.  The only difference is that using 5V (Vin), my USB to Serial doesn't power on, but with the 3.3V pin it does. But still, I can't see the NodeMCU in the device manager, only the usb to serial device.
I did not soldered anything to the board and nothing is plugged in.  Nothing is getting hot and I'm not sure if it is supposed to have some led ont the board to light up, but nothing happen
Am I missing something or my device is defect?
Thanks for your help.


texts: Turning LED On/Off by using SIM808 with Arduino Mega

texts:
I am trying to turn an LED on/off by using GSM 808 module. Here #a0 = LED off and #a1 = LED on. I have used lcdShow function to display characters in LCD display. But nothing appears on display. What is wrong in this code?

#include <SoftwareSerial.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
//I2C pins declaration
LiquidCrystal_I2C lcd (0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
SoftwareSerial SIM808 (10, 11);
char inchar;
const int LED = 2;

void setup ()
{

    Serial.begin (9600);
    SIM808.begin (9600);
    delay (10000);
    SIM808.print ("AT+CMGF=1\r");
    delay (100);
    SIM808.print ("AT+CNMI = 2,2,0,0,0\r");
    delay (100);

    lcd.begin (16, 2);
    lcd.backlight ();

    delay (1000);

    pinMode (LED, OUTPUT);
    digitalWrite (LED, HIGH);
}

void loop ()
{
    if (SIM808.available () > 0)
    {
        inchar = SIM808.read ();
        if (inchar == '#')
        {
            lcdShow (inchar);
            delay (10);
            inchar = SIM808.read ();
            if (inchar == 'a')
            {
                lcdShow (inchar);
                delay (10);
                inchar = SIM808.read ();
                if (inchar == '0')
                {
                    lcdShow (inchar);
                    digitalWrite (LED, LOW);
                }
                else if (inchar == '1')
                {
                    lcdShow (inchar);
                    digitalWrite (LED, HIGH);
                }
            }
        }
        SIM808.println ("AT+CMGD = 1,4");
    }

}

void lcdShow (char i)
{
    lcd.setCursor (0, 0);
    lcd.print (i);
    delay (5000);

}


texts: MPU6050 Sending Bad values for Angular Velocity

texts:
The mpu gives me perfectly fine values for the yaw, pitch, and roll position of the chip, but when I use mpu.getRotation(&gx, &gy, &gz) to obtain the current angular velocity of the chip, the values returned are awful. I wrote a program in Processing to graph the data from my Arduino, and this is what it looks like:

I suggest you click on the picture and zoom in a bit because it's difficult to see. The green line represents zero (0), the Pink line represents the angular position of the mpu6050 chip, obtained from mpu.getYawPitchRoll..., and the Blue line represents the angular velocity on the same rotational axis.

A few extra things to note:

The scale between the Pink and the Blue lines is slightly off, but that shouldn't matter for this purpose.
The time-frame for this graph is about 16s.
Before being graphed, the raw gx value is divided by the gyro's sensitivity scale factor, 131, and then converted from radians to degrees.
In addition to this, it is also put through a complementary filter, so the whole formula looks like this: rollRate = (0.7*rollRate) + (0.3*(-180 * gx / 131 / M_PI));

As you can see, the measurements for angular velocity (Blue) make almost no sense when graphed next to the angular position (Pink).

My question is this: What can I do to clean-up/filter these angular velocities and get rid of all the errors? I need these values to be accurate enough to be used in something like a drone PID.

Things I have tried:

Complementary filters of various proportions.
Adjusting the MPU's built in low-pass filter.

Thanks for any suggestions.


texts: How to use the native USB of the Arduino Due for high-speed communication?

texts:
All the Arduino examples involving communication via USB I could find use a virtual COM Port.

On the Arduino part it's

Serial.begin(baudrate);
Serial.write(byte);

And on the PC part it's just using a virtual COM Port.

However, the Arduino Due includes a native USB port, without all that UART+FTDI chip. I couldn't find any examples using the native interface, it seems everyone is content with communicating using the simple but slow way of Serial.write();.

How can I make full use of the native USB port, besides directly accessing the registers of the Cortex-M3, which seems to be a very tedious and complicated process? The data I would like to transmit is both large and time-critical, so I need to take care of buffer sizes, transfer types, etc., so writing characters one at a time to a general-purpose serial interface is not enough. The PC endpoint (I'm considering using libusb) should also see a proper USB device instead of a virtual COM port.


texts:
I have a program which measures temperatures every 30 minutes and sends them to a database. Immediately after running the program the first measurement is sent, however, the second (which should be sent after 30 min), is sent only after 1 hour. From then on the code works fine. The time is measured in millis. However, if I set the time difference to 28 minutes everything works fine from the beginning. What could be the reason for this? Is there a possibility that it goes to sleep mode? I don't understand why it works fine with 28 minutes and it stops working with 29 minutes?
Thanks in advance!
My code:
if (millis() - sendDataPrevMillis > 1740000)
  {
    sendDataPrevMillis = millis();

//other code

}

The only part I change, so it works is setting millis from 1740000 (29 minutes) to 1680000 (28 minutes).


texts: How much time passes between waking up and sleeping?

texts: I use the watchdog timer to make Arduino sleep for 8 seconds and then wake it right after and make it sleep again if it didn't complete the loop for 450 times. I made it so that it will only do its job every 1 hour with a for loop. How much time does the Arduino keep awake until it sleeps again? I think it wouldn't be worth to put power consumption of this to calculation but still need to verify.


texts:
I am looking at purchasing a NeoPixel Ring for a project, but need it to work without an Arduino. Once the NeoPixel has been programmed by the Arduino, will it function when powered without the Arduino? I am not looking at changing colors or anything, I want to set the LEDs to solid red and not change.

I have found in the Adafruit website that it says "NeoPixels don’t just light up on their own; they require a microcontroller (such as Arduino) and some programming." But is this only to get them working initially, or do they require an microcontroller permanently?


texts:
So I have this old RC car which doesn't seem to connect to the joystick very well so im going to modify it with an Uno with 433 MHz receiver/transmitter.

Both the steer and drive motors work as intended so long as you can reverse their current. I've seen people use the dual channel drivers which is what I know I probably what I should use to drive the motors. I bought a starter kit a while back which came with a single L9110H Chip. I thought maybe I could order another one and just solder them to a PCB and mount the PCB along with the Uno inside the car that way I don't have an extra chip just collecting dust. I've looked at the data sheet for the L9110H and came up with a diagram on Fritzing.

I was hoping someone could tell me if I'm on the right track with this?


texts: Communicate/Configure with Pro Micro (using Joystick.h) from within Windows

texts:
I'm creating some Joystick-like controllers to augment simulator games.
I usually use the Joystick library from MHieronimus which has worked great so far.
Now, I'm using some non-momentary rocking switches and would like to change the behaviour of some of them depending on the game I'm currently playing:

In one mode, the according Joystick button should be "pressed" and "released" depending on the switch. So, if I flip the switch to "ON", the Joystick button is set to "pressed" until I flip the switch to "OFF".
In the other mode, the according Joystick button should be pressed and released every time I flip the switch (for games that don't support rocking switches/maintained activation of buttons).

I could of course reprogram the SparkFun Pro Micro every time but I'm looking for an easier solution that can be operated from windows. I'm thinking of some sort of program (like the Logitech Profiler, Roccat Swarm or any other helper Software for input devices). That program should tell the Arduino how to act on switch flips / inputs.
Is it possible? What's the recommended way to do this?
Example code:
#include <Joystick.h>

Joystick_ Joystick;

int timer = 50;
int pins[] = {2, 4, 5, 6};
int btns[]=  {2, 4, 5, 6};
int btncount = sizeof pins;
int last_states[sizeof pins];

void setup() {
  for (int i=0; i < btncount; i++) {
    pinMode(pins[i], INPUT_PULLUP);
    last_states[i] = 0;
  }
  Joystick.begin();
}

void loop() {
  for (int i = 0; i < btncount; i++) {
    int current_state = !digitalRead(pins[i]);
    if (current_state != last_states[i]) {
      Joystick.setButton(btns[i], current_state);
      last_states[i] = current_state;
    }
  }
  delay(timer);
}

Let's say pins 4, 5 and 6 are rocking switches.


texts: Trying to use an Arduino Uno together with an ISM330DLC communicating through SPI

texts:
I am trying to get a MEMS-module (ISM330DLC) to work together with an Arduino Uno but I can't get it to work. I am using the ism330dlc drivers.

ISM330dlc Drivers: https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/ism330dlc_STdC

ISM330dlc Datasheet: http://www.farnell.com/datasheets/2339632.pdf

ISM330dlc Application Notes: https://www.st.com/content/ccc/resource/technical/document/application_note/group0/68/eb/a3/cd/2c/78/45/41/DM00468454/files/DM00468454.pdf/jcr:content/translations/en.DM00468454.pdf

I have switched out the voltage regulator to a 3.3V on the Arduino following this guide: https://learn.adafruit.com/arduino-tips-tricks-and-techniques/3-3v-conversion

I am using the STEVAL-MKI182V2 board for easier wiring.
This is the current wiring:

Arduino Pin<------------->STEVAL Pin

Pin 10 (SS)<------------->CS

Pin 11 (MOSI)<------------->SDA

Pin 12 (MISO)<------------->SDO

Pin 13 (SCK)<------------->SCL

SDx is connected to ground, SCx is connected to VddIO. The board is also connected to ground on the Arduino as well as Vin 3.3V.

Here is the code:

/* SPI Pin config (There are other pins dedicated to SPI I think) */
#define SSpin 10
#define MOSIpin 11
#define MISOpin 12
#define SCKpin 13

/* Variables used to store data */
static axis3bit16_t data_raw_acceleration;
static axis3bit16_t data_raw_angular_rate;
static float acceleration_mg[3];
static float angular_rate_mdps[3];

static int32_t platform_write(void *handle, uint8_t Reg, uint8_t *Bufp, uint16_t len) {
  SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE3));
  digitalWrite(SSpin, LOW);
  SPI.transfer(Reg);
  SPI.transfer(Bufp);
  digitalWrite(SSpin, HIGH);
  SPI.endTransaction();
  return 0;
}
static int32_t platform_read(void *handle, uint8_t Reg, uint8_t     *Bufp, uint16_t len) {
  Reg |= 0x80; //Set bit 0 (MSB) in order to read
  SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE3));
  digitalWrite(SSpin, LOW);
  SPI.transfer(Reg);
  *Bufp = SPI.transfer(0x00); //Dummy send to get value from module
  digitalWrite(SSpin, HIGH);
  SPI.endTransaction();
  return 0;
}

/* Init mems driver interface */
ism330dlc_ctx_t dev_ctx = {platform_write, platform_read, 0};
//dev_ctx.write_reg = platform_write;
//dev_ctx.read_reg = platform_read;
//dev_ctx.handle = 0; //No handler needed

void setup() {
  delay(100);
  Serial.begin(9600);
  pinMode(SSpin, OUTPUT);
  digitalWrite(SSpin, HIGH);

  /* Initialize SPI */
  SPI.begin();
  //SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0));     //MSBFIRST, SPI_MODE3

  /* Needed for setup */
  static uint8_t whoamI, rst;

  /* Check if device ID is correct */
  whoamI = 0;
  ism330dlc_device_id_get(&dev_ctx, &whoamI);
  while (whoamI != ISM330DLC_ID) {
    Serial.print("Wrong device ID!! \n"); Serial.print("whoamI: ");     Serial.print(whoamI); Serial.print("\n\n"); delay(50);     ism330dlc_device_id_get(&dev_ctx, &whoamI);
  }

  /*Restore default config */
  ism330dlc_reset_set(&dev_ctx, PROPERTY_ENABLE);
  do {
    Serial.print("reset:"); Serial.print(rst); Serial.print("\n\n");
    ism330dlc_reset_get(&dev_ctx, &rst);
  } while (rst);

The problem is that whenever I run this code I get DeviceID 255 no matter what (ism330dlc device id is 106). One thing I noticed is that if I reset the Arduino and quickly insert the USB cable and upload the code (in the time interval of a second) I can get the right device ID, but then I can't restore the default configuration (i.e not read or write again). Any tips what might cause this? I have tried SPI.setClockDivider() as well as different SPI Modes.

UPDATE: Removing ground from GND, SCx and SDx makes me get the correct deviceID but I still get stuck on trying to restore default configurations.


texts: Weird probled with TFT LCD screen and DHT22 sensor

texts:
I'm doing a research project that uses three sensors (DHT22, HTU21D and TMP102) and two screens (a normal 16x2 LCD, and a TFT).

I connected all the sensors and the LCD in my Arduino Uno and everything works fine. However, when I connect the TFT, the TFT simply freezes and does nothing. I ran the example Arduino sketches for TFT and it works fine. I also did a bit of debugging and found that if I don't invoke the DHT22 sensor reading functions (i.e., dht.readTemperature()), the TFT screen works fine.

I also triple-checked the wiring and it doesn't seems that something is wrong.

Any ideas why this behaviour occurs? Thanks.


texts:
Using an Arduino Mega. I have a motor hooked up exactly like the picture below. Using a BC548B transistor, 1N4001 diode, 220 ohm resistor and a 9V battery. I'm driving the motor in code by using PWM analogWrite to value 255. Weird thing is, if hooked up to USB (5V), the motor will only start to move after a certain amount of time, seems like it needs some initial "drive" to get started. If using the 9V battery it starts up quicker, but still not directly, as I would expect. Also, if I set analogWrite to some value less than 255, it will not move at all - is the transistor limiting? Can I change the resistor value to compensate? Thanks for any advice.

int motorPin = 3;
int interval = 10;
int walkingTime = 7.5;
bool walking = false;

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

void loop() {
  delay(interval * 1000);
  if (!walking) {
    startWalk();
    delay(walkingTime * 1000);
    stopWalk();
  }
}

void startWalk() {
  walking = true;
  analogWrite(motorPin, 255);
}

void stopWalk() {
  walking = false;
  analogWrite(motorPin, 0);
}


texts: Running ESP8266 at 3.78V to work with ATMEGA328P at 16 MHz

texts:
I have a project that is powered by 2x 18650 battery and feeds it to a step down switching voltage regulator that is configured to give a steady output of 3.78V to both esp8266 and atmega328p.

The esp8266 only sends an HTTP post request to an API every 30 mins and on standby mode whenever it does not do anything.
I have tested it for 1 hour and the esp8266 seems to work fine and does not warm. I intend to use the esp8266 in an airconditioned office 24/7 or until the battery runs out. I know it is not safe to give 3.78V because its supposed to have only a maximum of 3.6V but I am asking if anyone has ever had the same application and did not experience any problems?


texts: So for my project, I am measuring heartbeat of a person in a span of 10s. However, as the number of heartbeats may differ for each person, is it wise to use a vector?