texts: Unable to find arduino on device manager

texts:
I have just got a new Arduino robot for Christmas and I have plugged my robot into my computer and I have read the instructions from the manual that the robot was provided with and told me to go to the device manager in the control panel and look under unknown devices, unfortunately I was unable to find it. However I looked under ports and I found that there were 3 ports, I eventually found out that if I took the Arduino plug in and out of my PC that port COM5 was the Arduino, the problem I am having now is to know how to get this port to recognise my Arduino

one error that always comes up when trying to upload the code onto COM5 is this:

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

This is what the arduino looks like

Link for where I brought the arduino kit from:
https://www.amazon.co.uk/ELEGOO-Tracking-Ultrasonic-Intelligent-Educational/dp/B01M6YHRJ4/ref=sr_1_1_sspa?keywords=elegoo+robot&qid=1577982862&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyVjVXTk9VMDlUTTg1JmVuY3J5cHRlZElkPUEwMjc4NjYwOEVGNEoxM1Y0QzIwJmVuY3J5cHRlZEFkSWQ9QTA4OTA1NzAzTTNBVFJMV09aVjJRJndpZGdldE5hbWU9c3BfYXRmJmFjdGlvbj1jbGlja1JlZGlyZWN0JmRvTm90TG9nQ2xpY2s9dHJ1ZQ==

This is what shows up on the arduino IDE when I select COM5 (which should be my arduino)


texts:
I'm experiencing an issue with an Arduino Mega 2560 :
I powered the board through the Vin using a +24 --> 9V voltage regulator. When I power the board and measure the 5V output from the board, the voltage quickly drops from 5 to ~3V within seconds.

However, while powering with USB, the 5V output from the board gives us a clear 4.8V.

I have checked the 9V Voltage regulator (connected to the Vin), and it has a +24V input which remains stable (as should the 9V).

Any thoughts ?


texts: Reversed Input Voltage Arduino Mega timeout communication with programmer error

texts:
On the barrel connector I accidentally reversed the input voltage to an Arduino Mega. The center post received ground while the outer connection received +12DVC, basically I have the Arduino -12VDC. I have since fixed this problem. When I power the Arduino with the USB I am able to program the Arduino without a problem. When I power the Arduino with the +12VDC the program still runs (confirmed by programming the blink sketch). If I have the +12VDC connected and try to program the Arduino then I get the timeout communication error.

Do I just need to re-burn the bootloader? The Arduino's symptoms match those listed here when both cables are connected: Arduino Mega timeout communication with programmer error

Is there anything else I should verify? Or is the Arduino always going to be damaged?

Also as a note I did the same thing to an Arduino Uno (same rail going to both) and the Uno has no problems when both USB and power are connected.


texts: How do I create a state machine for my purpose?

texts:
I am new to Arduino.

I have a motor which drives a sliding door back and forth. The motor is connected to an H bridge which has two control pins (direction, speed). I have a switch which is intended to activate the motor for a set amount of seconds to open the door fully. When the switch is deactivated, the motor reverses for the same duration as opening.

I have written some basic code using the 'if' argument, but my issue is that the code under the 'if' argument loops when my switch is activated/deactivated whereas I want it to run once per switch activation. Looking online I saw that a state machine may be my solution, but my lack of expertise with coding means I cannot create a state machine. This is my code:

const int Switch = 2;
const int hbridge1 = 13;
const int hbridge2 = 12;
const int threshold = 400;

int buttonState = 0;

void setup() {

  pinMode(hbridge1, OUTPUT);
  pinMode(hbridge2, OUTPUT);
  pinMode(Switch, INPUT_PULLUP);

  Serial.begin(9600);
}

void loop() {
  int buttonState = digitalRead(Switch);
  Serial.println(buttonState);

  if (buttonState == HIGH) {
    digitalWrite(hbridge1, HIGH);
    digitalWrite(hbridge2, LOW);
    delay(4000);
    digitalWrite(hbridge1, LOW);
    digitalWrite(hbridge2, LOW); //I only need the motor to activate for four seconds, but 'if' loops it infinitely
  } else {
    digitalWrite(hbridge1, LOW);
    digitalWrite(hbridge2, HIGH);
    delay(4000);
    digitalWrite(hbridge1, LOW);
    digitalWrite(hbridge2, LOW); //Same issue  here
  }

;
  delay(1);
}


texts: Arduino not running the sketch with external power supply of 9v, but runs the program when connected to pc

texts:
Can anyone please help me figure out/ point the reason of this arduino problem? I uploaded a simple arduino sketch (blink an LED ) just to test if my real program was the reason of the "abnormality" of this board. It works fine when I connected it to PC via arduino cable, but doesn't run the program when I use an external power supply(9v) and connected it to the Vin pin of arduino.

Need help and hoping for fast replies. I will be having a competition tomorrow, this is very urgent. please guys.

for the schematic diagram, there are no other parts inserted to the arduino board, aside from the 9v battery. I was able to say that the program work on "LED blink" by observing the lights of "TX" LED on the board. please help me. :(


texts: How do I know which is ground and power in Piezo?

texts: I have a piezoelectric sensor. Both pins are the same length. I have one like this: Piezo picture. On the Piezo it's written muRata and 01P. How do I know which do I send to the digital pins and which to the ground? I have an Arduino Uno.


texts: Serial.println with string variable causing issue

texts:
I have a NodeMcu chip that I am attemping to run a script to create a file and read back from it.
#include <ESP8266WiFi.h>
#include <iostream>
#include <fstream>
#include <string>

const char *ssid = "testing"; // replace with your wifi ssid and wpa2 key
const char *pass = "sdfdsfsdfsf";

WiFiClient client;
using namespace std;
void setup() {
  Serial.begin(9600);
  delay(10);

  Serial.println("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print("Could not connect");
  }

  Serial.println("");
  Serial.println("WiFi connected");

  ofstream file;
  file.open("test.txt");

  if (file.is_open()) {
    file << "Writing this to the file";
    Serial.println("file has been created and opened");
    file.close();

    std::string lp;
    ifstream toread;
    toread.open("test.txt");
    while (getline(toread, lp)) {
      // This script runs fine, and uploads to the board, but if
      // I uncomment the below line, and try to write this string
      // variable to the serial monitor, it fails.
      // Serial.println(lp);
    }
  } else {
    Serial.println("could not create file");
  }
}

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


texts: Comparing button presses to correct sequence

texts:
I am creating a memory game with the Arduino. It has four buttons, each for a different colored led. The leds will blink in a random sequence and either fail or add another light in the next sequence if the user presses the correct buttons. I have also attached an lcd screen to late implement a score tally.

Right now, the welcome lights display and the sound is working fine, but when the sequence starts, it will act as though I am pressing a button and proceed through the fail light method. I think the last method is causing this issue where I am comparing the button pressed to the sequence.

I would appreciate any help!

This is essentially my wiring just with different pins chosen:


texts: Homemade soil moisture analog value reading jumping from 0 to max

texts:
I made a soil moisture sensor out of two metal poles, adjustable resistor, for a project I am making. The first run with the project the sensor worked amazing and gave clear and concise readings, 0-800 depending on water. I then unhooked the sensor and left it in the soil while I fine tuned the code (added warnings to the areas that would read to low), and while testing the code without the sensor being hooked up my arduino uno (Sparkfun Pro Mini) would read a value of 330(area). I thought this strange but didnt worry about it.

Well I hooked up my sensor (just power, ground, and to the A1 pin) and now my readout for the readings jump from 0 to 800, 0 to 512, 0 to another random number. I commented out everything in the code BUT the part that sets up the pin and displays the analog reading and its still the same issue. I also checked all my wires, changed the resistor setting, changed to a 10k single resistor, nothing changed.

Does anyone have any idea on what could be wrong?


texts: What are some steps to attach an Arduino to an electric heater?

texts:
I have the below portable electric heater, but I would love to control it's start AND stop time using an Arduino. As-is, it does not come with a stop feature. SO, I have a burning question. How can I get an Arduino to start and stop this heater at specific times of the day?

As you can see, it does have a start time, but it does not have a stop time.
The power button is a simple push button. I suspect I would need to 'interject' into that and the board by using a switch? Apologies if the terminology is off, but I'm very green.
Where would a noob begin?

-EDIT-
The unit is always off when it's plugged back in. That likely means I cannot put a timer on the power cord.


texts: Unable to read Arduino+ESP8266 full get Response

texts:
Using below code I am able to invoke HTTP Get request, but I am not able to read full HTTP Response. Observing only output like( +IPD,0,141:HTTP/1.7. ). Please let me know how can I read full response?
Any Idea what is the issue?
#include <SoftwareSerial.h>

#define RX 2
#define TX 3
String WIFI_SSID = "xyz";       // Your WiFi ssid
String PASSWORD = "xys";         // Password

String HOST = "192.168.0.156";
String PATH = "/test";
String PORT = "8080";

int countTrueCommand;
int countTimeCommand;
boolean found = false;

SoftwareSerial esp8266(RX, TX);

void setup() {
  Serial.begin(9600);
  esp8266.begin(9600);
  esp8266.println("AT");
  Serial.println(esp8266.read());
  sendCommandToESP8266("AT", 5, "OK");
  sendCommandToESP8266("AT+CWMODE=1", 5, "OK");
  sendCommandToESP8266("AT+CWJAP=\"" + WIFI_SSID + "\",\"" + PASSWORD + "\"", 20, "OK");
}

void loop() {
  String postRequest = "GET " + PATH  + " HTTP/1.1\r\n" +
                       "Host: " + HOST + "\r\n" +
                       "Accept: *" + "/" + "*\r\n" +
                       "\r\n";

  sendCommandToESP8266("AT+CIPMUX=1", 5, "OK");
  sendCommandToESP8266("AT+CIPSTART=0,\"TCP\",\"" + HOST + "\"," + PORT, 15, "OK");
  String cipSend = "AT+CIPSEND=0," + String(postRequest.length());
  sendCommandToESP8266(cipSend, 4, ">");
  sendData(postRequest);
  readESP8266(8000);
  sendCommandToESP8266("AT+CIPCLOSE=0", 5, "OK");
}

void sendCommandToESP8266(String command, int maxTime, char readReplay[]) {
  Serial.print(countTrueCommand);
  Serial.print(". at command => ");
  Serial.print(command);
  Serial.print(" ");
  while (countTimeCommand < (maxTime * 1))
  {
    esp8266.println(command);
    if (esp8266.find(readReplay))
    {
      found = true;
      break;
    }

    countTimeCommand++;
  }

  if (found == true)
  {
    Serial.println("Success");
    countTrueCommand++;
    countTimeCommand = 0;
  }

  if (found == false)
  {
    Serial.println("Fail");
    countTrueCommand = 0;
    countTimeCommand = 0;
  }

  found = false;
}

void sendData(String postRequest) {
  Serial.println(postRequest);
  esp8266.println(postRequest);
  delay(1500);
  countTrueCommand++;
}

void readESP8266(const int timeout)
{
  String reponse = "";
  long int time = millis();
  while( (time+timeout) > millis())
  {
    while(esp8266.available())
    {
      reponse+=esp8266.readString();
    }
  }
  Serial.print(reponse);
}

Output:
Success
1. at command => AT+CWMODE=1 Success
2. at command => AT+CWJAP="xyz","xys" Success
3. at command => AT+CIPMUX=1 Success
4. at command => AT+CIPSTART=0,"TCP","192.168.0.156",8080 Success
5. at command => AT+CIPSEND=0,56 Success
GET /test HTTP/1.1
Host: 192.168.0.156
Accept: */*

busy s...

Recv 56 bytes

SEND OK

+IPD,0,141:HTTP/1.7. at command => AT+CIPCLOSE=0 Success


texts: How do I measure watts without a CT clamp?

texts:
I'm trying to build an "IoT" project for home that will in effect create a smartplug. I'd like to add the capability to measure the watt usage of the plug (and whatever's connected to it). I'd like to not use a CT clamp for this purpose, and I was hoping someone here can help.

I have a 220 V mains connection and I'd like to measure the watts used by a connected appliance to the smart plug is a small as possible form. CT sensors are too big for this purpose.

Thanks.


texts: Powering Arduino with 12V AC-DC Adapter Jack

texts:
I have 12V,700mA AC-DC adapter power jack. Is it ok power on arduino board directly using this power jack?

Though Arduino webpage suggests that arduino can stand and upto 20V power supply, I ask this because somewhere it is written that supply 12v, 700mA will end up the board to smoke and need a converter to make it 5V.

Is this correct?

Thanks,
Jyoti Raj


texts: WebClientRepeating not printing response to Serial

texts:
I'm following the tutorial in WebClientRepeating and it says that "The content of the page is viewable through your Arduino's serial window." However the output in my Serial window is just saying "Connecting..." repeatedly.

Here is my code:

    /*
  Repeating Web client

 This sketch connects to a a web server and makes a request
 using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
 the Adafruit Ethernet shield, either one will work, as long as it's got
 a Wiznet Ethernet module on board.

 This example uses DNS, by assigning the Ethernet client with a MAC address,
 IP address, and DNS address.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13

 created 19 Apr 2012
 by Tom Igoe
 modified 21 Jan 2014
 by Federico Vanzati

 http://www.arduino.cc/en/Tutorial/WebClientRepeating
 This code is in the public domain.

 */

#include <SPI.h>
#include <Ethernet.h>

// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(10, 1, 1, 4);

// fill in your Domain Name Server address here:
IPAddress myDns(10, 1, 1, 1);

// initialize the library instance:
EthernetClient client;

char server[] = "www.arduino.cc";
//IPAddress server(64,131,82,241);

unsigned long lastConnectionTime = 0;             // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
// the "L" is needed to use long type numbers

void setup() {
  // start serial port:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // give the ethernet module time to boot up:
  delay(1000);
  // start the Ethernet connection using a fixed IP address and DNS server:
  Ethernet.begin(mac, ip, myDns);
  // print the Ethernet board/shield's IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // if there's incoming data from the net connection.
  // send it out the serial port.  This is for debugging
  // purposes only:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if ten seconds have passed since your last connection,
  // then connect again and send data:
  if (millis() - lastConnectionTime > postingInterval) {
    httpRequest();
  }

}

// this method makes a HTTP connection to the server:
void httpRequest() {
  // close any connection before send a new request.
  // This will free the socket on the WiFi shield
  client.stop();

  // if there's a successful connection:
  if (client.connect(server, 80)) {
    Serial.println("connecting...");
    // send the HTTP GET request:
    client.println("GET /latest.txt HTTP/1.1");
    client.println("Host: www.arduino.cc");
    client.println("User-Agent: arduino-ethernet");
    client.println("Connection: close");
    client.println();

    // note the time that the connection was made:
    lastConnectionTime = millis();
  } else {
    // if you couldn't make a connection:
    Serial.println("connection failed");
  }
}

Here are my Mac's network settings.

It's my understanding that I can assign an IP address to my Ethernet shield by just changing the last number of my computers IP address. Hence I changed 10.1.1.5 to 10.1.1.4.

Can anyone see any obvious errors? This is not really my area of expertise :)


texts:
I'm trying to send data over serial and pick it up in a ruby script. I'm using the serialport gem (https://rubygems.org/gems/serialport) as stated in the Arduino docs (http://playground.arduino.cc/Interfacing/Ruby).

My question is, I'm trying to print out some gyroscope data, particularly the x, y, and z. This is what my arduino sketch looks like:

void setup() {
  Serial.begin(9600);
  // ... do some gyro stuff here
}

void loop() {
  gyro.read();

  Serial.print((int)gyro.g.x);
  Serial.print(" ");
  Serial.print((int)gyro.g.y);
  Serial.print(" ");
  Serial.print((int)gyro.g.z);

  delay(500);
}

My ruby script is pretty straight forward as well:

require "serialport"
port_str = "/dev/tty.usbmodemfa141"
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE

sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
while true do
  message = sp.gets
  if message
    message.chomp!

    puts message
  end
end

However, the output that I get is choppy. What I mean by that is that the numbers don't come out as a single line as I intend:

52 9
5
250
 -28
 85
25
9 -5
1 69

Even if I replace it with "Hello World", it'll come out as:

He
llo
Wor
ld

or similar.

Any ideas why? Thanks in advance for any help.


texts: Why is my liquid crystal display not showing any output?

texts:
UPDATE:
The LCD will light up only when the all my components are located in the bottom right of the breadboard. Why am I not able to use the entire breadboard for my circuit?
I am trying to display data from a temperature and humidity sensor on the serial monitor and the liquid crystal display.
I am using :

Arduino Uno R3
I2C 16x2 LCD Module
3 pin DHT11 sensor

Here is my code :
#include <dht.h>                // initialize the digital temperature and humidity sensor library ("DHTlib")
#include <LiquidCrystal_I2C.h>  // initialize the liquid crystal display library ("LiquidCrystal I2C")
#include <Wire.h>               // intialize the wire library

/*   the first parameter is the I2C address
 *   the second parameter is how many columns are on your screen
 *   the third parameter is how many rows are on your screen
*/
LiquidCrystal_I2C lcd(0x27, 16, 2);

dht DHT;              // create a handle to call functions from the sensor library
#define DHT11_PIN 7   // assign a digital pin number to the sensor
float TempC;          // create a variable to store temperature in celsius
float TempF;          // create a variable to store temperature in fahrenheit
float Humi;           // create a variable to store humidity

void setup()
{
  lcd.init();                // initialize liquid crystal display
  lcd.backlight();           // turn on the backlight of the lcd
  pinMode(DHT11_PIN,INPUT);  // configure the pin for the sensor as an input for reading the data
  Serial.begin(9600);        // set data rate in bits per second for serial data transmission
}

void loop()
{
  // collect sensor data
  int chk = DHT.read11(DHT11_PIN);  // store sensor data in a variable
  TempC = DHT.temperature;          // store temperature in Celsius
  TempF = 9 / 5 * TempC + 32;       // store temperature in Fahrenheit
  Humi = DHT.humidity;              // store relative humidity as a percentage

  // display sensor data on LCD
  lcd.setCursor(0,0);    //tell the screen to write on the top row
  lcd.print("T: ");
  lcd.print(TempC);    // print the temperature in Celsius
//  lcd.print(TempF);    // print the temperature in Fahrenheit
  lcd.print((char)223);  // print the degree symbol
  lcd.print(" C");
//  lcd.print(" F");
  lcd.setCursor(0,1);    // tell the screen to write on the bottom row
  lcd.print("H: ");
  lcd.print(Humi);       // print the humidity
  lcd.print(" %");

  // display sensor data on the serial monitor
  Serial.print("Temperature = ");
  Serial.print(TempC);     // print the temperature in Celsius
//  Serial.print(TempF);     // print the temperature in Fahrenheit
  Serial.print("\xc2\xb0");  // print the degree symbol
  Serial.println(" C");
//  Serial.println(" F");
  Serial.print("Humidity = ");
  Serial.print(Humi);        // print the humidity
  Serial.println(" %");

  delay(2000);  //delay fetching the next sensor values for 2 seconds
}

My jumper wires are connected as follows:

DHT plus → red plus row
DHT middle → digital pin 7
DHT minus → blue minus row
LCD GND → blue minus row
LCD VCC → red plus row
LCD SDA → analog pin A4
LCD SCL → analog pin A5
Red plus row → 5V pin
Blue minus row → GND pin


texts:
I am trying to run a sensor from my switch using POE. I have created a temp/humidity sensor using the MySensors directions https://www.mysensors.org/about/arduino.  I decided to use a nano due to the USB connector. I have connected this to my switch via a TP-Link POE splitter set to 5 volt output.

When connected, the switch provides power for a second or two then turns off for 10 seconds or so before coming on again. I believe the Switch is testing the circuit not detecting enough power being drawn and shuts down. It then goes through the cycle again. Note: both the power LED on the switch and the nano LEDS light up while power is supplied. I believe the nano itself only uses about 20mA

I have tested with another device that requires 9volts (hand held phone) via the splitter and it works fine with power provided consistently.

I was wondering if there is some circuitry I can add before the Arduino that will draw a little more current but still provide a constant 5V to the nano.

Additional information. The switch is a Linksys LGS124P. I have tried to find more detail regarding the required power but can only find this datasheet that does not provide that level of detail
http://downloads.linksys.com/downloads/datasheet/1224699456700/25685_LINKSYS_unmanaged_POE_switches_PROD_Revised.pdf


texts:
I have three devices for making a motion activated security camera system:

this is the camera : LINK  OV 7670
this is the SD Card module: LINK
and a basic motion Sensor: PIR with 3 pin

I have an Arduino UNO and an Arduino Mega 2560.

I can connect the SD card and sensor, they work fine but I cannot connect the camera as there are not enough pins for it on UNO.

Is there a chance to connect all of them without any additional device?

I saw some working project with additional device (arducam) but I do not have much money to spend on this project.


texts: D1 mini esp8266 error: esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

texts:
I am pretty sure this device worked yesterday. I tried to short GPIO0 to ground (flash), nothing.
I have a second ESP that uploads fine, but this one does not.
Is their another way to get this bootloader to open up? Or am I the owner of a brand new door stop?


texts: delayMicroseconds not working on STM32F103C8T6

texts: Due to the fake STM32F103C8T6 module in the market, the delayMicroseconds function is working qucker than expected, when I expect a delay of 1000 us , I get a delay of 500 us. Is there a better method, like to create separate module for counting in microseconds using micros timer? Or there are other proper bootloaders than this one . I use Arduino IDE for programming STM32F103C8T6


texts: Retrieve value from ThingSpeak using ESP8266 with Arduino setup

texts:
I just started learning ESP8266 and in my first project I am successfully able to send data to ThingSpeak.com using ESP8266 with following code:

uploadData() {
  String apiKey = "ESDS8678890SDDS";
  String myData = "45.5"; // example of data to send
  if (espClient.connect(server,80)) {
    String postStr = apiKey;
    postStr +="&field1=";
    postStr += String(myData);
    postStr += "\r\n\r\n";
    espClient.print("POST /update HTTP/1.1\n");
    espClient.print("Host: api.thingspeak.com\n");
    espClient.print("Connection: close\n");
    espClient.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
    espClient.print("Content-Type: application/x-www-form-urlencoded\n");
    espClient.print("Content-Length: ");
    espClient.print(postStr.length());
    espClient.print("\n\n");
    espClient.print(postStr);
    Serial.print(postStr);
    Serial.print("My Data: ");
    Serial.print(myData);
    Serial.print("\n");
  }
  espClient.stop();
}

But I have no idea how to retrieve data from ThingSpeak using ESP8266.

// Using XXXXX here as my channel is private
GET https://api.thingspeak.com/channels/XXXXXX/fields/1.json?results=2

I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.

Help would be appreciated.

Thanks.


texts: Can I use an accelerometer to measure the velocity of a car in a curve?

texts:
I am making an application that is used to measure the velocity, it has an accelerometer that measures the component acceleration in the XYZ-axis. When the car is moving just straight the measurement is ok, as only linear components are involved.
My doubt came when the car is on a curve, I am not sure if the accelerometer can measure correctly in such situation or if it is necessary to apply a gyroscope to measure any missing component.
The code snippet for measure the total acceleration is shown below, I measure the acceleration in each axis and I remove the gravitational to finally calculate the velocity and the speed
    float AccTotal_X = ((AcX - grav_X)*9.81);
    float AccTotal_Y = ((AcY - grav_Y)*9.81);
    float AccTotal_Z = ((AcZ - grav_Z)*9.81);

    float Vx = vx_0 + AccTotal_X*dt;
    vx_0 = Vx;
    float Vy = vy_0 + AccTotal_Y*dt;
    vy_0 = Vy;
    float Vz = vz_0 + AccTotal_Z*dt;
    vz_0 = Vz;

    speed_dt = sqrt(pow(Vx,2)+pow(Vy,2)+pow(Vz,2))*3.6;


texts: Why the SoftwareSerial is not working properly on Arduino Pro Mini 3v3?

texts:
I uploaded regular pass through code for Serial and SoftwareSerial to communicate with my AT command based module.

Writing to SoftwareSerial seems to be working but reading not.
As I write "AT", the module returns me "-5" which should be "OK".

As I write "asdad" the module returns something similar ot "invalid syntax" but very messy.

#include <SoftwareSerial.h>
SoftwareSerial ss(rx, tx);

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

void loop() {
  while (Serial.available()) ss.write(Serial.read());
  while (ss.available()) Serial.write(ss.read());
}


texts: Why I could not read the other sms's except the first SMS?

texts:
I have to read the incoming SMS on my GSM module SIM900, and I want to print the sender number and message to the serial monitor.

I first configure the GSM module with AT commands and Response() function will give me the response to AT commands.

as any SMS will be in the following pattern

+CMT: "[Mobile number]", "[Date and Time]>"
   [message body]

So, I first extract +CMT and after that I will take mobile number and at last we have message body. The code I have used is

char RcvdMsg[200] = "";
int RcvdCheck = 0;
int RcvdConf = 0;
int index = 0;
int RcvdEnd = 0;
char MsgMob[15];
char MsgTxt[50];
int MsgLength = 0;

void Config() // This function is configuring our SIM900 module i.e. sending the initial AT commands
{
    delay(1000);
    Serial.print("ATE0\r");
    Response();
    Serial.print("AT\r");
    Response();
    Serial.print("AT+CMGF=1\r");
    Response();
    Serial.print("AT+CNMI=1,2,0,0,0\r");
    Response();
}

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

void loop()
{
  RecSMS();
}

void Response() // Get the Response of each AT Command
{
    int count = 0;
    Serial.println();
    while(1)
    {
        if(Serial.available())
        {
            char data =Serial.read();
            if(data == 'K')
            {
                Serial.println("OK");
                break;
            }
            if(data == 'R')
            {
                Serial.println("GSM Not Working");
                break;
            }
        }
        count++;
        delay(10);
        if(count == 1000)
        {
            Serial.println("GSM not Found");
            break;
        }
    }
}

void RecSMS() // Receiving the SMS and extracting the Sender Mobile number & Message Text
{
    if(Serial.available())
    {
        char data = Serial.read();
        if(data == '+'){RcvdCheck = 1;}
        if((data == 'C') && (RcvdCheck == 1)) {RcvdCheck = 2;}
        if((data == 'M') && (RcvdCheck == 2)) {RcvdCheck = 3;}
        if((data == 'T') && (RcvdCheck == 3)) {RcvdCheck = 4;}
        if(RcvdCheck == 4)
        {
            RcvdConf = 1;
            RcvdCheck = 0;
        }

        if(RcvdConf == 1)
        {
            if(data == '\n'){RcvdEnd++;}
            if(RcvdEnd == 3){RcvdEnd = 0;}
            RcvdMsg[index] = data;

            index++;
            if(RcvdEnd == 2){RcvdConf = 0;MsgLength = index-2;index = 0;}
            if(RcvdConf == 0)
            {
                Serial.print("Mobile Number is: ");
                for(int x = 4;x < 17;x++)
                {
                    MsgMob[x-4] = RcvdMsg[x];
                    Serial.print(MsgMob[x-4]);
                }
                Serial.println();
                Serial.print("Message Text: ");
                for(int x = 46; x < MsgLength; x++)
                {
                    MsgTxt[x-46] = RcvdMsg[x];
                    Serial.print(MsgTxt[x-46]);
                }

                Serial.println();
                Serial.flush();
            }
        }
    }
}

The problem of the code is

After receiving first SMS I am getting my mobile number and message body. After that I am only getting the sender number printed to my serial monitor but not the message body.

Where has it gone wrong. I could not understood.

Please help me.......Thanks in advance.


texts: Unable to upload program to Nano33 BLE Sense

texts:
I searched for answers on StackExchange but did not find any for the situation I am in.
I use a macBook pro to connect the recently procured Nano33 BLE sense via a USB cable.
I tried a couple of sketches and all worked well.
I then became a bit ambitious to try the this example:
The IMU capture went well trouble started when I used the IMU Classifier program
On the first attempt - I was able to compile and upload the classifier sketch and I could an initial response from the setup() on my serial monitor and after that nothing happens.
I suspected some serial comms issue so I tried the IMU Capture program just to see if all communications on serial port was normal - but was unable to upload the program and Arduino IDE did not give any error. It just kept saying uploading and the time taken was much longer than normal.
At this stage the Green LED is on, and Yellow keeps blinking.
As a result I am unable to replace the IMU Classifier program that was previously loaded and possible is the cause of issue with serial port.
I also checked if I can read board info - and that works (implying that there is some communication between macbook and nano33.
I restarted both macbook and nano33 but still cannot replace the program in the Nano with a new sketch.
What else can I do unlock this stalemate?
EDIT: found this issue logged (but still unresolved on GITHUB)
Question : Is there a way to erase the current program on nano33 outside of Arduino IDE?
EDIT: found a solution to reload sketch


texts: EEPROM programmer works with serial monitor but not with pySerial

texts:
I'm trying to modify Ben Eater's eeprom programmer to flash a 32K eeprom, since the arduino has 32K of program data total the data wouldn't fit in the program. So I wrote a python program using pySerial to send the data in chunks of 256 bytes over serial. The arduino program works correctly when I manually send the data over the serial monitor, and the python program works correctly when I print the values to a console as a test, but when I actually run the program over serial it seems to only write zeros to the eeprom. Additionally, the Rx led on the arduino seems to be lighting up with the correct data, but like I said only zeros are written.
Here's the relevant arduino code:
void setup() {
  pinMode(SHIFT_DATA, OUTPUT);
  pinMode(SHIFT_CLK, OUTPUT);
  pinMode(SHIFT_LATCH, OUTPUT);
  digitalWrite(WRITE_EN, HIGH);
  pinMode(WRITE_EN, OUTPUT);

  Serial.begin(57600);
  dataArrPage = 0;

  //delay(1000);
  //Serial.println("Reading EEPROM");
  //printContents();

}

void loop() {
  if (Serial.available() > 0) {
    int len = Serial.readBytes(dataArr, 256);

    for (int i = 0; i < 256; i++) {
      writeEEPROM(dataArrPage + i, dataArr[i]); // writeEEPROM(address, data)
    }
    dataArrPage += 0x100;

    Serial.write('s'); //success, writing is done
  }
}

And the relevant python code:
import time
import serial
ser = serial.Serial('/dev/ttyUSB0', 57600)
time.sleep(4) # wait for arduino to initialize

filename = input("Enter file name: ")
f = open(filename, "rb")
data = f.read()

page = 0
for x in range(128): # 128 pages in 32K eeprom
    for i in range(256):
        #print(hex(data[(page * 256) + i])) # printing prints the correct values
        ser.write(data[(page * 256) + i])
    page += 1

    #wait until receive 's' from arduino
    while True:
        if ser.in_waiting > 0:
            suc = ser.read(size=1)
            if suc == b's':
                print("Success")
                break

print("Writing done")
f.close()
ser.close()

I'm a beginner so sorry if it's something obvious.


texts: NodeMCU (ESP8266) Defining static IP, stops Firebase processing

texts:
Hello i am new to NodeMCU (ESP8266) i am building a small program to connect with WIFI (with internet) and if internet is not available i want to process request over IP address.

I am using firebase as a database / server to fetch the status. And process command through a URL like http://192.168.1.223/on?pin=04 if internet is connected then no problem i can update firebase entry, but with same network (LAN) connection over wifi i want to process i need to have static IP. But the concern is i am not able to make this IP address static, and if i make it static then my NodeMCU is not able to connect with firebase.

Here is how my code looks like:

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

#define FIREBASE_HOST "pushst-56f2c.firebaseio.com"
#define FIREBASE_AUTH "mhBpzrNyhhwEGwmFxkVFTIEylwrXMw0gm"
#define PATH "/clients/devicename/watermotor"

IPAddress ip(192, 168, 1, 223);  //Node static IP
IPAddress dns(192, 168, 1, 223);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);

char ssid[] = "MyNetwork";
char password[] = "Qwert98!!";

int wifiStatus = WL_IDLE_STATUS;

ESP8266WebServer server(80);

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

      delay(100);
      Serial.println();
      Serial.println();
      Serial.print("Your are connecting to;");
      Serial.println(ssid);

      WiFi.begin(ssid, password);
      WiFi.config(ip, dns, gateway, subnet);

      while (WiFi.status() != WL_CONNECTED) {
        digitalWrite(WIFI_CONNECT_LED, HIGH);
        delay(500);
        Serial.print(".");
      }

      wifiStatus = WiFi.status();

      if(wifiStatus == WL_CONNECTED){
          digitalWrite(WIFI_CONNECT_LED, LOW);

         Serial.println("Your IP address is: ");
         Serial.println(WiFi.localIP());

         Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
         Firebase.set("/clients/devicename/watermotor/name", "Motor");
         Firebase.set("/clients/devicename/watermotor/relay_status", "off");
         Firebase.set("/clients/devicename/watermotor/device_status", "online");
         Firebase.stream(PATH);

         server.on("/on", handleOnRequest); //Associate the handler function
         server.on("/off", handleOffRequest); //Associate the handler function

         server.begin(); //Start the server
      }
      else{
        Serial.println("");
        Serial.println("WiFi not connected");
      }

}

void loop() {
    server.handleClient();
    if (Firebase.failed()) {
      Serial.println("streaming error");
      Serial.println(Firebase.error());
      delay(1000);
      return;
    }

    if (Firebase.available()) {
        Serial.println();
        Serial.print("Firebase available");
        Serial.println();
        FirebaseObject event = Firebase.readEvent();
    }
}

I am not sure if its there is some problem with FirebaseLibrary or its just the ESP8266!

Any suggestions will be helpful, thanks in advance! :)


texts:
When I started connecting my Arduino Uno for first project: LED to pin 13, resistor, breadboard, USB connected to Windows Laptop, the orange on-board LED flashes every second and the LED on the breadboard did the same.
What program is driving this?
I had NOT uploaded any program.
Please explain.


texts: How can I generate a sinewave with Arduino Uno?

texts:
I would like to generate a sine wave with my Arduino Uno. As far as I know, there is no library for Uno to generate such a signal (correct me if I'm wrong), so the only option available is to write a function to generate the signal from scratch.

As far as my understanding of digital electronics goes, I believe it is possible to generate a sine wave signal by using PWM and varying the duty cycle accordingly. However, this route seems to me quite long, what other options do I have?


texts:
I was wondering if I would be able to use specific parts of the c++ library for my arduino sketch. For example the arduino library has a queue array but I wanted to use a priority queue for my sketch and I am unsure how to modify the queue header file to do that. Also if I can use the priority queue from the c++ library can you please tell me how I would go about doing that.

Thank-you


texts: About possibility of implementing kalman filter on atmega32

texts: I have searched on the internet on how to get Euler angels from IMU measurements,I found that kalman filter and mahony filter are used...kalman filter has a drawback of complex computations,but mahony has less computation,so mahony is preferred for 8 bit microcontroller,but accuracy of kalman is better than mahony,so my question is ,can we implement kalman filter with its complex computations on 8 bit microcontroller like atmega32


texts: Clear existing array when getting new serial command

texts:
I'm starting to build my first Arduino project but I'm running into some problems with serial communication.

I get serial data from the console and store it in a char array called "data".

Then, when I send a new console message to the Arduino, I want it to clear the existing "data" array and store only the new data in that array.

I don't understand exactly what's wrong with my code: I believe those nested Serial.available() statements don't work but I have no ideas on how to fix the code.

Data is correctly stored by the Arduino but it concatenates the newer string to the old one.

int count = 0;
char data[30];
boolean dataComplete = false;

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

void loop() {

  if (Serial.available() > 0){
    if (dataComplete == true){
    Serial.println("There is data already, clearing...");
    char data[30];
    dataComplete = false;
  }
    if (dataComplete == false){
      Serial.println("New command, collecting...");
      while (Serial.available()>0){
        char character = Serial.read();
        data[count] = character;
        count++;
      }
     dataComplete = true;
    }
  }
  Serial.print("Command received: ");
  Serial.println(data);
  delay(1000);
}

Thanks in advance!


texts:
I use official Arduino GSM Shield with Uno R3.

I uploaded web server examples from official GSM library. I use a simple python script to make TCP/IP connections to my GSM Shield web server. I send simple requests from my computer to shield, and it responses back.

At first, this worked like a charm. I even connected a led to arduino uno, and started turn it on and off. But after some time, I get timeout errors from my script.

I turned on debug mode of gsm shield. At first, it displayed normal stuff. When connection gone between my computer and shield, it doesn't showed anything on serial window.

I thought there is something wrong with shield, but when I send a request from my computer; light of the shield indicates that there is a transmission incoming; but nothing shows on serial window. I think after some time, connection between arduino and gsm shield gets broken.

What could be done to make this web server more stable? I don't want it stop working after half an hour.

Edit: Other than loop function, my code is same as web server example in the Arduino examples.

// I connected leds to D11 and D12 to see what happens during program.
void loop(){
  GSMClient client = server.available();

  digitalWrite (11, HIGH);

  if (client) {
    while (client.connected())
    {
      if (client.available())
      {
        char c = client.read();

        // when it receives 1, D12 pin is high for 3 seconds.
        if (c == '1') {
          digitalWrite (12, HIGH);
          delay(1000);
          client.stop();
          delay(2000);
          digitalWrite (12, LOW);
        }
      }
    }
  }
}


texts:
Just starting a project and wanting to connect Lolin D32 Pro board with OLED SH1106. The screeen works with my Arduino Nano no problem however I can't seem to get it working on the D32 Pro.
I tried different pins on the D32 and different libraries, no luck.

My code example is below and I connect pin 21 of D32 board to the sda pin of the screen and pin 22 of the d32 board to the scl pin of the screen. VCC & GND also are connected correspondingly

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>

#define OLED_SDA 21
#define OLED_SCL 22

Adafruit_SH1106 display(21, 22);

void setup()   {
  Serial.begin(115200);
  Serial.println("setup");
  /* initialize OLED with I2C address 0x3C */
  display.begin(SH1106_SWITCHCAPVCC, 0x3C);
  Serial.println("begin");
  display.clearDisplay();
  Serial.println("clear");

}
void loop() {
    Serial.println("loop");

  /* set text size, color, cursor position,
  set buffer with  Hello world and show off*/
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Hello, world!");
  display.display();
  delay(2000);
  display.clearDisplay();
}

Please help me out with the code example or something to read. I suspect I am missing something around D32 Pro board pins


texts: How can I seriously calibrate ADC voltage readings with Arduino Nano?

texts:
I have been using Arduino Nano Analog input to measure voltages, in the range between 22-30 Volts.

I want to measure it down to a tenth of a volt.

Following the instructions found here:

Read Analog Voltage (www.arduino.cc)

Which basically states that all I need is this code:

int sensorValue = analogRead(A0);
float voltage= sensorValue * (5.0 / 1023.0);

5.0/1023 = 0.004888 volts per increment in analog readings.  Turning that around, voltage input divided by this value should give me the sensor value.
Clearly they are presuming an input of 0-5 Volts.

My voltage divider is 1 Mohm (R1) between the voltage input and A2, then 200K (R2) from A2 to ground

30 Volts measures as 4.2 Volts.  22 Volts measures as 3.1 Volts.

I think the range between 22 volts and 30 Volts doesn't present enough variation to the ADC - every single-digit change in the analogRead really make a big difference.

The result is that it is giving me some crazy readings.  It is definitely nonlinear, so I am having real trouble trying to get it to be accurate at both ends of my measurement range.  Each slight ADC increment makes too much of a difference in the measured voltage because I am not using the full 0-5V input range.

So I have been taking 10 readings in a row, at 500 ms intervals, then averaging.

And yet it is not working well enough.

(The biggest problem was the reference voltage and resolution were assumed to be 5/1024 which is completely incorrect.  Unless, as someone pointed out, I fed the Nanos directly at the 5V pin - which is still on the table - then it would be 5/1023)

I changed my resistor network to be 147K/23.5K

(Parts list:  1x 100K, 3x 47K)

R1 = 47K / 47K = 23.5K

R2 = 100K + 47K = 147K

Also added a 100uF 50V electrolytic across the input from the battery bank I am monitoring.

I am feeding 5V to Vin.  And have figured out that the reference is measurable on the 5V pin, after the regulator, as 4.6V.

Knowing that

Resolution/Vref = ADC/Vin

I turned that around to be

Vin = ADC * (Vref/Resolution)

Or, Vin = A2 * (4.6/1023)

Using a laboratory power supply I was able to confirm that with those settings 22 Volts came in at 3 Volts, and 29.98 came in right at 4 Volts.

So

Vbat = A2 * (4.6/1023) / (R2/(R1+R2))

Vbat = A2 * (4.6/1023.0)/(147000/170500)

It is now operating reasonably well.

(Yellow means the inverter is on)

--UPDATE--
  Changed resistors to 100K/20K for the divider and brought power to the 5V pin, bypassing the regulator for a reference.  It measures at 5.02 and is stable.

Results:

Charge controller meter says I am at 24.5 Volts.

Program says 24.64  (in the serial monitor).

--ADDENDUM:  I want to pursue the Op-Amp setup.  But if 741 won't work will need a suggestion.

Similarly, I went to 147K/47K for the 11-15 Volt circuit, and moved a higher-quality P/S over to the 5V pin, where it measures 5.03V; the results are better there, too. Just very slightly high.

So anyway, I'll put this to rest until I can figure out an op-amp circuit.

Thank you all for your help


texts: Is it possible to insert your own routine into the Reset procedure

texts:
I'm working with  ATmega328 NANO boards, and I would like to know if it is possible to INSERT my own routine, to be included in the things done during reset, BEFORE any pre-C initialization is done, or any upload of new code occurs. If this is possible, I'd like to know how. I'd want to be able to "install" this routine during setup(). I also would not expect it to work after a power loss. I'm talking about a reset caused by pressing the reset button, uploading code, opening a serial port, or any reset that was NOT caused by a loss of power.

I'm including a simple example sketch illustrating what I would LIKE to do, but it obviously won't do what I want as written, because I do not know the "magic" answer I'm seeking,

I've defined and initialized a global static byte outside of any functions. The setup() simply reads a byte from EEPROM and displays it with Serial.print(), and then stores its value in that global 'number'.  Now notice I created a void(void) function called magic(). It simply increments the global number and stores it in EEPROM. I call it "magic() because what I need to do to call it is unknown. I want some way to "install" magic() during setup(), so that it runs only as part of the reset process, before anything within code or data space is affected. By install, I don't mean just call the function. It should not actually be called unless RESET occurs.   Whatever "magic" has to be added to make this happen, the proof of the pudding will be that after loading the sketch. every time you press RESET, or even upload the sketch again, the printed number will be different, because it was incremented and saved when reset was pushed. NOTE: (I just edited some stupid errors here)

#include <EEPROM.h>

static uint8_t number =0;

void setup()
{
  uint8_t n = EEPROM.read(0);
  Serial.begin(57600);
  Serial.print(n);
  number = n;

  // somehow, install "magic" routine here

}

void loop() { }

void magic(void)
{
 ++number;
 EEPROM.write(0, &number);
}


texts:
I cannot understand the code of controlling the speed of brushless dc motor using ESP8266 WiFi Module.

I found it in- https://ubidots.com/blog/speed-control-for-brushless-motors-with-an-esp8266-2/

The part that I cannot understand is-

float btof(byte * payload, unsigned int length) {

  char * demo = (char *) malloc(sizeof(char) * 10);

  for (int i = 0; i < length; i++) {

    demo[i] = payload[i];

  }

float value = atof(demo);

  free(demo);

  return value;
}

// Callback to handle subscription

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

{

    value = btof(payload, length);

      value = map(value, 0, 1023, 0, 180);

//Map the 0-100 values from the slider to the 0-180 to use the servo lib.

 ESC.write(value);

//Send the value (PWM) to the ESC

}

Please help me with the code!


texts:
I am using ESP12E Wifi module, using library based on Arduino. Is there any way I can upload hex file of the project to esp8266 using Arduino or any tool?
I need to send hex file instead of code to my client. Is there any way?


texts: Can't send DHT11 temperature data to Xively from Yun

texts:
I thought this would be easy but how wrong I am... All I want to do is plot temperature data but I can't seem to get it to work. It reads it out on the serial monitor and says it has sent the data (in the serial monitor) but nothing on the Xively plots! Why?? Below is the code.

I have the API key and feedID from the Xively site. The useragent I'm assuming is the name of the project. My channels are called sensorValue1 and sensorValue2. Please help - this is taking me far too long.

#include <Bridge.h>
#include <Console.h>
#include <Process.h>

#include "DHT.h"
#define DHTPIN 0
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

 #define APIKEY "BLablablablabla" // your pachube API key
 #define FEEDID blablabla // your feed ID
 #define USERAGENT "SebYun2" // user agent is the project name

// set up net client info:
const unsigned long postingInterval = 60000; //delay between updates to xively.com
unsigned long lastRequest = 0; // when you last made a request
String dataString = "";

void setup() {
  // start serial port:
  Bridge.begin();
  Serial.begin(9600);
  dht.begin();
  while(!Serial); // wait for Network Serial to open
  Serial.println("Xively client");
  // Do a first update immediately
  updateData();
  sendData();
  lastRequest = millis();
}

void loop() {
  // get a timestamp so you can calculate reading and sending intervals:
  long now = millis();
  // if the sending interval has passed since your
  // last connection, then connect again and send data:
  if (now - lastRequest >= postingInterval) {
    updateData();
    sendData();
    lastRequest = now;
  }
}

void updateData() {
  // convert the readings to a String to send it:
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  dataString = "Temperature,";
  dataString += dht.readTemperature(false);
  delay(250);
  // add pressure:
  dataString += "\nHumidity,";
  dataString += dht.readHumidity();
  int sensorValue1 =  analogRead(A0);
  delay(100);
  int sensorValue2 =  analogRead(A0);
  dataString += "\nVoltage1,";
  dataString += sensorValue1*0.0049;
  Serial.print(sensorValue1);
  dataString += "\nVoltage2,";
  Serial.print(sensorValue2);
  dataString += sensorValue2*0.0049;
  delay(1000);
}

// this method makes a HTTP connection to the server:
void sendData() {
  // form the string for the API header parameter:
  String apiString = "X-ApiKey: ";
  apiString += APIKEY;
  // form the string for the URL parameter:
  String url = "https://api.xively.com/v2/feeds/";
  url += FEEDID;
  url += ".csv";
  // Send the HTTP PUT request
  // It is better to declare the Process here, so when the
  // sendData function finishes the resources are immediately
  // released. Declaring it global works too, BTW.
  Process xively;
  Serial.print("\n\nSending data... ");
  xively.begin("curl");
  xively.addParameter("-k");
  xively.addParameter("--request");
  xively.addParameter("PUT");
  xively.addParameter("--data");
  xively.addParameter(dataString);
  xively.addParameter("--header");
  xively.addParameter(apiString);
  xively.addParameter(url);
  xively.run();
  Serial.println("done!");
  // If there's incoming data from the net connection,
  // send it out the Serial:
  while (xively.available()>0) {
    char c = xively.read();
    Serial.write(c);
  }
}


texts: Serial not displaying sketch for MPU6050

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

Where he provided the code below. The problem I'm having is the serial monitor shows nothing. I tried changing the baud to 115200 and still nothing showed up. I'm using an Arduino nano.

Update: I wrote a Serial.print in each function (printing the name of the function), and I found it just printed up to "recordAccelRegisters" then stopped. Then I put a Serial.print after each line in the function, and it prints until the line
while(Wire.available() < 6);
Is this a problem with the while function or I2C?

Ok, so I reinstalled Arduino and got this message on the serial print with the I2C test:

"Scanning... I2C device found at address 0x69  ! done."

#include <Wire.h>

long accelX, accelY, accelZ;
float gForceX, gForceY, gForceZ;

long gyroX, gyroY, gyroZ;
float rotX, rotY, rotZ;

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

void loop() {
  recordAccelRegisters();
  recordGyroRegisters();
  printData();
  delay(100);
}

void setupMPU(){
  Wire.beginTransmission(0b1101000); //This is the I2C address of the MPU (b1101000/b1101001 for AC0 low/high datasheet sec. 9.2)
  Wire.write(0x6B); //Accessing the register 6B - Power Management (Sec. 4.28)
  Wire.write(0b00000000); //Setting SLEEP register to 0. (Required; see Note on p. 9)
  Wire.endTransmission();
  Wire.beginTransmission(0b1101000); //I2C address of the MPU
  Wire.write(0x1B); //Accessing the register 1B - Gyroscope Configuration (Sec. 4.4)
  Wire.write(0x00000000); //Setting the gyro to full scale +/- 250deg./s
  Wire.endTransmission();
  Wire.beginTransmission(0b1101000); //I2C address of the MPU
  Wire.write(0x1C); //Accessing the register 1C - Acccelerometer Configuration (Sec. 4.5)
  Wire.write(0b00000000); //Setting the accel to +/- 2g
  Wire.endTransmission();
}

void recordAccelRegisters() {
  Wire.beginTransmission(0b1101000); //I2C address of the MPU
  Wire.write(0x3B); //Starting register for Accel Readings
  Wire.endTransmission();
  Wire.requestFrom(0b1101000,6); //Request Accel Registers (3B - 40)
  while(Wire.available() < 6);
  accelX = Wire.read()<<8|Wire.read(); //Store first two bytes into accelX
  accelY = Wire.read()<<8|Wire.read(); //Store middle two bytes into accelY
  accelZ = Wire.read()<<8|Wire.read(); //Store last two bytes into accelZ
  processAccelData();
}

void processAccelData(){
  gForceX = accelX / 16384.0;
  gForceY = accelY / 16384.0;
  gForceZ = accelZ / 16384.0;
}

void recordGyroRegisters() {
  Wire.beginTransmission(0b1101000); //I2C address of the MPU
  Wire.write(0x43); //Starting register for Gyro Readings
  Wire.endTransmission();
  Wire.requestFrom(0b1101000,6); //Request Gyro Registers (43 - 48)
  while(Wire.available() < 6);
  gyroX = Wire.read()<<8|Wire.read(); //Store first two bytes into accelX
  gyroY = Wire.read()<<8|Wire.read(); //Store middle two bytes into accelY
  gyroZ = Wire.read()<<8|Wire.read(); //Store last two bytes into accelZ
  processGyroData();
}

void processGyroData() {
  rotX = gyroX / 131.0;
  rotY = gyroY / 131.0;
  rotZ = gyroZ / 131.0;
}

void printData() {
  Serial.print("Gyro (deg)");
  Serial.print(" X=");
  Serial.print(rotX);
  Serial.print(" Y=");
  Serial.print(rotY);
  Serial.print(" Z=");
  Serial.print(rotZ);
  Serial.print(" Accel (g)");
  Serial.print(" X=");
  Serial.print(gForceX);
  Serial.print(" Y=");
  Serial.print(gForceY);
  Serial.print(" Z=");
  Serial.println(gForceZ);
}

https://github.com/VRomanov89/EEEnthusiast/blob/master/MPU-6050%20Implementation/MPU6050_Implementation/MPU6050_Implementation.ino


texts: ESP8266 sometimes stuck on AT+CIPSEND with "busy s..."

texts:
I'm using an ESP8266-01S Wi-Fi module on an Arduino UNO.

When I use AT+CIPSEND=4 and then type test it successfully sends that message to my laptop. However, sometimes the module returns a busy s... after typing the message... Then the module board is "frozen" for a couple of seconds to a full minute before accepting other commands.

What's a way to make sure the message gets send without getting that busy s... response. Or how do I catch it and reset the board or something like that?


texts: Why is there no embedded c code in arduino libraries?

texts:
When I took a look at how the arduino libraries were coded I expected to see register names like I/O registers(PINx,DDRx,PORTx) and other such registers with values assigned to them but instead I saw normal C code with functions and a class.

Why isn't there any embedded C in the structure of the library? Am I misunderstanding something very basic? Please help me understand.


texts:
I combined two different codes together, a captive portal and a SD card web server. I encountered a problem which the website in the SD card doesn't load when I connect to the AP (captive portal page). Here's the code..

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include "./DNSServer.h"
#include <SPI.h>
#include <SD.h>

const byte        DNS_PORT = 53;          // Capture DNS requests on port 53
IPAddress         apIP(10, 10, 10, 1);    // Private network for server
DNSServer         dnsServer;              // Create the DNS object
ESP8266WebServer server(80);
String responseHTML = ""
                      "<title>Captive Portal Test</title>"
                      "
TEST
";

static bool hasSD = false;
File uploadFile;

void returnOK() {
  server.send(200, "text/plain", "");
}

void returnFail(String msg) {
  server.send(500, "text/plain", msg + "\r\n");
}

bool loadFromSdCard(String path) {
  String dataType = "text/plain";
  if (path.endsWith("/")) path += "index.htm";
  if (path.endsWith(".src")) path = path.substring(0, path.lastIndexOf("."));
  else if (path.endsWith(".htm")) dataType = "text/html";
  else if (path.endsWith(".css")) dataType = "text/css";
  else if (path.endsWith(".js")) dataType = "application/javascript";
  else if (path.endsWith(".png")) dataType = "image/png";
  else if (path.endsWith(".gif")) dataType = "image/gif";
  else if (path.endsWith(".jpg")) dataType = "image/jpeg";
  else if (path.endsWith(".ico")) dataType = "image/x-icon";
  else if (path.endsWith(".xml")) dataType = "text/xml";
  else if (path.endsWith(".pdf")) dataType = "application/pdf";
  else if (path.endsWith(".zip")) dataType = "application/zip";

  File dataFile = SD.open(path.c_str());
  if (dataFile.isDirectory()) {
    path += "/index.htm";
    dataType = "text/html";
    dataFile = SD.open(path.c_str());
  }

  if (!dataFile)
    return false;

  if (server.hasArg("download")) dataType = "application/octet-stream";

  if (server.streamFile(dataFile, dataType) != dataFile.size()) {
  }

  dataFile.close();
  return true;
}

void handleNotFound() {
  if (hasSD && loadFromSdCard(server.uri())) return;
  String message = "SDCARD Not Detected\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " NAME:" + server.argName(i) + "\n VALUE:" + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
}

void setup(void) {
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
  WiFi.softAP("TEST AP");
  dnsServer.start(DNS_PORT, "*", apIP);
  //PROBLEM HERE/
  server.onNotFound([]() {
  server.send(200, "text/html", responseHTML);
  });

  server.begin();

  if (SD.begin(SS)) {
    hasSD = true;
  }
}

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

This code replies the responseHTML as a Captive portal page which immediately pop-ups when I connect to the AP:

server.onNotFound([]() {
      server.send(200, "text/html", responseHTML);
      });

The void handleNotFound() handles the page/file request from the browser but if I use it on

server.onNotFound(handleNotFound);

The captive portal won't show but if I type the server address 10.10.10.1, the page will appear. What seems to be the problem?


texts: Can't get 4 digit 7 segment display to show different values

texts:
I'm an Arduino newbie having problems getting a 4 digit 7 segment display to work. The display is connected to a 74HC595 and the setup is from the elegoo tutorial 28 (I think it is download only).

I figured how to control which number to display, but all 4 digits always share the same number, so it is always like 1111, 5555, 9999 etc.

I've heard about something called multiplexing which might do the trick, but I can't adapt it to my project yet, missing too much experience.

This is the code that toggles between 2222 and 8888.
I want to be able to display any number like 1234 though.

Any help is very appreciated.

int latch=9;  //74HC595  pin 9 STCP
int clock=10; //74HC595  pin 10 SHCP
int data=8;   //74HC595  pin 8 DS

void setup()
{
  pinMode(latch,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(data,OUTPUT);
}

void Display(unsigned int num)
{
  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,num);
  digitalWrite(latch,HIGH);
}

void loop()
{
    Display(91);
    delay(1000);
    Display(127);
    delay(1000);
}


texts: Reading iBeacon Data using HC-05 bluetooth module

texts:
I have bought a HC-05 bluetooth module for Arduino.

My requirement is to read data transmitted from iBeacon, is it possible using HC-05 or I have to shift to HM-10?


texts: How can I use my Arduino sketches on my Raspberry Pi IDE?

texts:
I have installed the Arduino IDE 2:1.0.5 on my Raspberry Pi3 under Raspbian and am using a cobbler breakout which provides a nice breadboard.  On that breadboard I have installed an Arduino Nano to do analog voltage readings, which it then communicates back to the Rpi3 via the USB serial port which shows up as /dev/ttyUSB0 on the Rpi3.

This port opens as a regular file in Python for further processing such as adding a date & time stamp (obtained by an NTP server) and saving the results to a data file that is displayed in gnuplot 4.6.

You'll notice I am using 3.3 Volts for the fan to keep it quiet, and the two wires heading up to the top go to the voltage source I am monitoring.  If you look closely you can see the voltage divider circuit.

Here is today's solar plant voltages which this thing tracks.  The block at the bottom means the inverter was on.  Green means the battery bank is full.

Anyway, it turns out that the same serial connection is supported by the Rpi Arduino IDE for programming.

Rather than programming the Nano on a laptop and constantly having to unplug/replug it on the breadboard my goal is to use Rpi Arduino IDE for programming.

So I moved all my sketches over from the Arduino IDE on the laptop to the Rpi.

But

.... then every time I start the Rpi IDE it throws error messages for all the sketches that have underscores in their names.  Turns out the Rpi version will only allow alphanumeric directory names.  I have a couple dozen sketches and this is not productive.  It requires clicking OK for every directory it skips - which turns out to be all of them.

So my question is:  What can I do about this?


texts:
Some days ago i started a thread.
concatenation of non constant character array with a sting

I have a different question but on the same nature (string and chars)

what i want is one variable (string or char) that will hold a standard text and the value of gps coordinates latitude and longitude

The format is this: "latitude/longitude: 30.111111 20.111111"

What i have is a char that holds the standard text and the latitude: "Latitude/Longitude: 30.111111"

I also have another char that holds the second value (longitude)

The chars were generated with dtostrf():

char clat[10 + 20 + 1] = "Latitude/Longitude: ";
char clng[10 + 1];
dtostrf(gps.location.lat(), 10, 6, clat+20);
dtostrf(gps.location.lng(), 10, 6, clng);

I can also make the chars strings:

string1 = String(clat);

What have i tried:
1.Assigning clng to clat directly via dtostrf()

char clat[10 + 20 + 10 + 1] = "Latitude/Longitude: ";
dtostrf(gps.location.lng(), 10, 6, clng+31);

It didnt work and got unexpected output

making clat a string and assign clng via for loop

string1 = String(clat);
    for (int i=0; i<10; i++)
    string1[i+32]=clng[i];

This doesnt append it

I run out of ideas here.
Any help from more experienced guys?


texts:
I am not really 100% too sure how to do this but I am trying to make my arduino UNO communicate with my arduino MEGA. The reason why I needed to do this was because I was using the RFID module along with a TFT display and the problem I faced is that on the arduino mega they both needed pin 53. Luckily I have an arduino UNO so I just went for that instead for the display. I am trying to use the analogWrite() function to send analog signals from my MEGA over to the UNO so that the TFT display on the UNO can display the results. The UNO would also read the analog inputs coming from the MEGA. This did not work very well. The analog inputs are being sent from the MEGA but the UNO is not reciving them. I am using a PWN pin on the MEGA to send the analog output to the UNO.
This diagram shows what I mean:

These are the 2 compotents I am using:
https://i.stack.imgur.com/CqXdB.png
TFT display

RFID

This shows how the libary sets out the pins. I am only a beginner so I personally don't want to mess around with the libary.


texts: How to get number of available pins in code?

texts:
Different boards have different number of pins.

Is there a way to know this number in code (at least digital and analog pins), or do I have to determine board type (like in this thread) and know the number of pins by myself?

Reasoning for this is that I'm creating prototype using Uno and using 2-3 analog pins for temperature readings, but I want to be able to use the same code for different board in the future with eg. 8 analog pins, so I don't have to remember to change pin numbers in code and maybe solder it convenient way etc. Also being able to use for eg. "last available analog pin" for certain job could help keep code/schematics nice and clean.


texts: Unspecified running error while programing WeMos D1 in wireless mode

texts:
I've tried to program WeMos D1 directly by wireless connection. I've test my D1 so it had no problem. after setting SSID and Password I've programed it for wireless using. It ran well. as I want to programing thought wireless there was an Unspecified error for running python.exe !
java.io.IOException: Cannot run program "python.exe": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:26)
    at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:129)
    at cc.arduino.packages.uploaders.GenericNetworkUploader.uploadUsingPreferences(GenericNetworkUploader.java:99)
    at cc.arduino.UploaderUtils.upload(UploaderUtils.java:78)
    at processing.app.SketchController.upload(SketchController.java:709)
    at processing.app.SketchController.exportApplet(SketchController.java:682)
    at processing.app.Editor$DefaultExportHandler.run(Editor.java:2190)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
    at java.lang.ProcessImpl.start(ProcessImpl.java:137)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 8 more
An error occurred while uploading the sketch

I've python on my PC  and it works. to clear my problem I've attached  the following gif

any help would be appreciated.


texts: Changing PWM on Arduino Mega, pins 9 & 10 to 20 to 25 KHz

texts:
I'm trying to run a Nema 17 motor with a l298N motor Driver for a school project. The issue is that I am running the motor with PWM to avoid overheating of the driver, however the resulting noise at the default frequency is extremely aggravating.

How can I change the frequency for pins 9 & 10 to 20-25 KHz? Any tips tricks and code examples would be highly appreciated (emphasis on code examples).


texts: Is it possible to use Arduino PWM for audio within a PAM8493 amplifier?

texts:
I've seen some projects using PWM for playing audio files, and it seems like it needs an amplifier, otherwise the sound is very low.

I already made a project using a DFPlayer and PAM8403, but now I need more control over the files in the SD Card which is not supported by the DFPlayer library, so it seems like I need to use PWM and a SD Card module, instead of a separate audio module.

My questions are, can I simply connect the PWM output to the amplifier (PAM8403) and I will be able to control volume (using the programming language) and have a good quality sound?


texts: Connecting an arduino uno to an arduino due

texts:
So I am trying to get my arduino uno to talk to my arduino due but I'm having issues getting the data outputted on the due side. My arduino uno is the master while the due is the slave. The sensor is connected to the uno and I just require the arduino due to receive and spit out the data as it has a faster sampling rate than the arduino uno. I connected them along the serial (Tx and Rx) lines. And I'm using Serial3 on my arduino due to receive the transmitted data. Both arduinos are grounded together. But powered differently by usb cables connected to my machine. On the arduino uno end ( for brevity sake) the data is sent in binary with the $ sign as the starter bit. Here is the code for the receiving end ( the slave). I just can't seem to get the data out on the serial monitor.

    byte b = '$';
    unsigned char buffer[12];
    int count =0;

    void setup() {
    Serial.begin(115200);
    Serial3.begin(115200);
    delay(5);

    }

   void loop() {
   if(Serial.available())
   {
    if (b == Serial.available())
   {
    while(Serial.available())
    {
      buffer[count++] = Serial.read();
       if(count == 12)break;
      //Send the byte to serial port three
      Serial3.write(buffer, count);
    }
 }

 if (Serial3.available()){
  //get a byte from serial port 3
  if(b == Serial3.available()){
    buffer[count++] = Serial3.read();
    //Send the byte to the USB serial port
    Serial.write(buffer, count);
  }
 }
 Serial.println("lyca");
 }
  }


texts: Convert my if loop code into a switch/case statement

texts:
I have made a project where in photosensors constantly read value and if laser is cut by external object, then it beeps the buzzer.

A switch case would make it easy, as suggested by some people.
I have written my short code below, can you kindly help me change it?

Converting all if loops into a switch/case statement.

 int sensorPin = A0;
 int sensorPin1 = A1;
 int sensorPin2 = A2;
 int sensorPin3 =  A3;
 int sensorValue0 = 0;
 int sensorValue1 = 0;
 int sensorValue2 = 0;
 int sensorValue3 = 0;
 const int BUZZER = 9;
 const int BUZZER1 = 7;
 const int BUZZER2 = 8;
 const int BUZZER3 = 5;

void setup() {
 Serial.begin(9600);
 pinMode(BUZZER, OUTPUT);
 pinMode(BUZZER1, OUTPUT);
 pinMode(BUZZER2, OUTPUT);
 pinMode(BUZZER3, OUTPUT);
 // put your setup code here, to run once:
}

void loop() {
  sensorValue0 = analogRead(sensorPin);
  sensorValue1 = analogRead(sensorPin1);
  sensorValue2 = analogRead(sensorPin2);
  sensorValue3 = analogRead(sensorPin3);
  Serial.println(sensorValue0);
  delay(100);

  if (sensorValue0>920)
   noTone(BUZZER);
  else
   tone(BUZZER, 500);

  if (sensorValue1>850)
   noTone(BUZZER1);
  else
   tone(BUZZER1, 300);

  if (sensorValue2>850)
   noTone(BUZZER2);
  else
   tone(BUZZER2, 700);
}


texts:
I think about building my own robotic mower, therefore I would like to detect if the surface the mower in moving on is grass, pavement, gravel ... etc.

Which sensors would be the best choice in order to achieve this?

The benefits:

no parimeter wire to bury
possible lawn edge detection (here most mowers fail to do a good job)


texts: 7segment blink when the button is pressed

texts:
I have programmed an IR remote control along with an LED and an 8bit 7segment on an Arduino Uno.
the segment displays the number I press via the remote, and the LED turns on and off
here's my code:

case 16738455:
  Serial.println(0);
  if (oldvalue == results.value){
    on(num0);
    delay(1000);
    on(num00);
    delay(1000);
    oldvalue = results.value;
  }

oldvalue stores the last value pressed, which is the DEC value of the buttons, num0 displays the number zero, and num00 turns all the segments off.
I want the 7segment to blink again when I press the same button again.
Can anyone help me with this?
Thanks


texts:
i just set up 2 displays ( 3 digit 7 segments ), and the displays seems to be blinkin ( i know they are suppose to blink but so fast that the human eye cannot detect it ).

I'm using the SevSeg Library and this is how my code looks:

void setup() {

   byte numDigits = 3;
   byte digitPins[] = {2, 3, 4};
   byte segmentPins[] = {5, 6, 7, 8, 9, 10, 11, 12};
   sevseg1.begin(COMMON_ANODE, numDigits, digitPins, segmentPins);

   byte digitPins2[] = {14, 15, 16};
   byte segmentPins2[] = {17, 18, 19, 20, 21, 22, 23, 24};
   sevseg2.begin(COMMON_ANODE, numDigits, digitPins2, segmentPins2);

}

void loop() {

  while(true){
     sevseg1.setNumber(number,0);
     sevseg2.setNumber(number,1);
     sevseg1.refreshDisplay();
     sevseg2.refreshDisplay();
  }
}

I need to add 2 more 3 digits 7 segment displays so i was wondering what is it that is causing the blinking.

Im using Arduino Mega.


texts: Low Power Library 4 seconds ON, 10 minutes OFF

texts:
Could someone please demonstrate how to use a counter with the Arduino 'low power' library to wait for 10 minutes then digitalWrite 4000, HIGH and loop. (I don't mean the simple 'blink' sketch).

I'm trying to save as much power as possible, so any advice is appreciated.

Thanks!


texts: Name of the Arduino Nano clone in the device manager

texts:
I'm working on an app using Matlab and it recieves data from an arduino. I've changed my board into an Arduino Nano (clone) recently. My program will automatically check for the device's name in the list of serial devices connected and it will connect to it directly once the user presses connect. The user doesn't have to input any Com port number or baud rate. This worked fine with my previous boards (UNO, Pro Micro, Leonardo). I just need to change the search string in my code and it'll automatically connect. My current board however is different, I'm using VMA102 (Arduino Nano clone). It uses FTDI drivers which I downloaded following this tutorial. I can upload the codes correctly to it but I just doesn't show a name with in the ports list in Arduino IDE as shown in the picture below.

Now when I looked it up in the device manager the name was 'USB Serial Port (COM5)' so I pasted 'USB Serial Port' as my search text in Matlab, it doesn't find it. I concluded that the correct name for it is not 'USB Serial Port' but rather the 'no name' as shown in Arduino IDE. Is there a way to find what is it called or how I can change it into a unique name so that my app can search for it?

Edit: here is the code, it works fine with all the other boards:
    devices = IDSerialComs();%gets all the avilabe com ports and thier names (name, com#)
    assignin('base','devices',devices);%save it to main workspace

i=1;index=0; tesst= zeros(length(devices),1);%saves the comparison results
while i<=length(devices)
    tesst(i)= strcmp(devices{i,1},'USB Serial Port');%compare the received names with the board's name
    % 'SparkFun Pro Micro''Arduino Uno'
    if ( tesst(i)==1 )
        index=i;%save the index
    end
    i=i+1;
end

if(isempty(find(tesst,1)))
    msgbox({'Connection failed' ' plug the device, wait for 5 seconds then try again'} ,'Connection Failure','error');
else
    msgbox('Connection successful, proceed to the next tabs', 'Connection success');
end
%get the COM# associated with the index and add COM before it to from the comport number as a string
COM_Num = strcat('COM',num2str(devices{index,2}));
comport= serial(COM_Num, 'BaudRate', 115200);

and here is a screenshot of my device manager

Thanks


texts: Strange power comsuption into sleep mode

texts:
I've finished my project and now I'm measuring the current but there is something wrong. I'm using an Arduino Pro Mini board and the LowPower library but the consumption is about 3.5 - 5 mA and not less than 500 uA (the board remains into sleep mode almost all the time).

When I began to work with the board its LED was removed but I think that this work was not made correctly. How can I check that LED was removed correctly?

Thanks to all.

EDIT1: The strange power consumption is not associated with board's LED.

EDIT2: @Gerben has suggested me to review the state of SPI pins connected to the board. I use in this project a SD card module and GSM/GPRS module but the guilty of this excessive power consumption is the first. Then I've disconnected all SD card module's pins and then I get about 60 uA, so the problem is on those pins but I can't reduce the power consumption. SD card module pins are 10,11,12 and 13 so I've used statements like digitalWrite(10, LOW), digitalWrite(11, LOW) and so on after reading/writing on the SD card but it is useless.

EDIT3: I've decided to upload a representation of my project using Fritzing. The external modules are not identical but they contain the same pins.

General view of the circuit:.

Detail of the connections:

I use these external components:

SD card module
A6 GPRS/GSM module

In my project there are some important details:

GPRS module is powered individually. The other battery is dedicated to power on the Arduino board and the SD card module.
Batteries are 6v.
Transistors base are controlled by 2 and 3 digital pins respectively.
The 8 and 9 pins of the Arduino board act like RX and TX pins using AltSofSerial.h library.


texts:
I am using SIM800 Module with Arduino Micro. It reponds well to basic AT commands. But i am unable to send SMS from this module as:

AT+CMGF=1 ERROR

Now while further debugging i saw AT+COPS? Returns 0, means not connected to any operator. That may be causing the CMGF failure. But my AT+COPS=? returns multiple operator. I have an Airtel working sim. Intialyy it was showing AIRTEL too in AT+COPS=? but not now.. anything to do with signal??

AT+COPS?

+COPS: 0

OK AT+COPS=?

+COPS: (2,"405800","405800","405800"),(1," IDEA CELLULAR Ltd","IDEA","40404"),(1,"40505","40505","40505"),,(0-4),(0-2)

What is going wrong here. any inputs?


texts:
guys.

I'm writing here because I cannot find an obvious error, so I'm stuck. Could you please help me?

Here's the code:

int arrayAAA[] = {6, 8, 10, 12};
int arrayBBB[] = {9, 15, 27, 41};

const int arrayAAALength = sizeof(arrayAAA)/sizeof(int);
const int arrayBBBLength = sizeof(arrayBBB)/sizeof(int);

int newArrayLength = 0;

void setup() {

    Serial.begin(9600);

}

void loop() {

  String dir = "AAA";

  if (dir == "AAA"){

      //Copy existing array to the new one...
      newArrayLength = arrayAAALength;              //Get the size of source array
      int newArray[newArrayLength];                 //Make the new array of the same size
      memcpy(newArray, arrayAAA, sizeof(arrayAAA)); //Copy content of the source array to the new one

      /*
      for (int i = 0; i < newArrayLength; i++){
          Serial.print(newArray[i]); //Here everything works just fine...
          Serial.print("   ");
      }
       */
  }

  for (int i = 0; i < newArrayLength; i++){
      Serial.print(newArray[i]); //But here I see this error: 'newArray' was not declared in this scope
      Serial.print("   ");
  }

  Serial.println();
  Serial.println();

}

What I'm trying to do is to copy the array to a new one, but depending on the circumstances I need to take different source arrays (AAA or BBB).

The problem is in checking the values of an newly crreated array:

'newArray' was not declared in this scope

if I try to check its valus outside of if statment.

It seems my stupid mistake, but I can't find it.


texts: Creating variable inside if statement (conditional signed vs unsigned int)

texts:
I have an SPI chip that I would like to read out with an Arduino. Some of the registers are signed int others are unsigned int. I am writing a function to read any register.

A simplified version:

readRegister(byte thisRegister, char type) {

  if(type == 's'){
    signed int result;
  }else{
    unsigned int result;
  }

  // take the chip select low to select the device:
  SPI.beginTransaction(SPISettings(2500000, MSBFIRST, SPI_MODE3));
  digitalWrite(SlaveSelectPin, LOW);

  //now get the value
  result = SPI.transfer16(thisRegister);

  // finish up
  digitalWrite(SlaveSelectPin, HIGH);
  SPI.endTransaction();

  // return the result:
  return (result);
}

readRegister(0x4B87,'s')  //read signed int register
readRegister(0xB357,'u')  //read unsigned int register

However this doesn't work since the variable result is created inside the if statement so the scope is wrong. I get error: 'result' was not declared in this scope on the SPI.transfer() line.

How to solve this?


texts:
I am having trouble uploading a new program to my arduino micro. I first flashed the blink example program to the board and that worked. However now whenever I try to flash a new program it either cannot fine the port of it just gives me a general error. I have selected the right model and port in the tools menu as well as press the reset button right before the upload stage. This arduino micro has an external power supply. Here is the error code:

Sketch uses 4,244 bytes (14%) of program storage space. Maximum is 28,672 bytes.
Global variables use 154 bytes (6%) of dynamic memory, leaving 2,406 bytes for local variables. Maximum is 2,560 bytes.
PORTS {COM1, COM4, } / {COM1, COM4, } => {}
PORTS {COM1, COM4, } / {COM1, COM4, } => {}
PORTS {COM1, COM4, } / {COM1, COM4, } => {}
PORTS {COM1, COM4, } / {COM1, COM4, COM9, } => {COM9, }
Found upload port: COM9
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -PCOM9 -b57600 -D -Uflash:w:C:\Users\Joel\AppData\Local\Temp\build4becb324f24d9ea6a5bead572d36ff0a.tmp/d4onOF.ino.hex:i
An error occurred while uploading the sketch.

Com 1 and 4 are default to this computer

Thanks in advance for your help.


texts: can I give the 9v input power for arduino mega 2560 using vin pin?

texts:
I am using Arduino mega 2560. I have some doubts about powering my microcontroller.
Can I use the 9v battery to power my arduino through the VIN terminal?
I have uploaded an image. Check whether it is a correct method or not?


texts: Problem uploading big program to arduino

texts:
I have an arduino duemilanove with ATmega328.

Been doing several experiments with multiple peripherals

I had no problem uploading at all

But when i try to upload a big program (27,074 bytes (of a 30,720 byte maximum))
it compiles fine, then says uploading...

After some time passes i get this error

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

The board and serial port connections are fine.
Any ideas?

PS: Then i tried to upload the blink example, but i get the same error for some reason
Everything worked fine before i uploaded my "big" program


texts: How can I use wifi to wirelessly communicate (and wirelessly code if possible) between multiple arduinos?

texts: I am using arduino as the base for an accelerometer project - the end goal is to have multiple arduinos with accelerometer chips that can wirelessly start and stop collecting data and wirelessly send this data back to the "base" arduino (which will be connected to a computer).  Currently we have only two arduinos communicating to test a lot of this, and currently are using a bluetooth node to wirelessly code the accelerometer arduino and Rf nodes to wirelessly send the data back to the arduino connected to a computer which then prints the data it is collecting.  How could we replace this with a wifi network?


texts: Strange compiler error (Segmentation Fault)

texts:
You're getting a compiler error. It happens in strange parts of code that really shouldn't be having a problem.  The error looks something like:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.15.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp:203:1: internal compiler error: Segmentation fault

}

^

Please submit a full bug report,

with preprocessed source if appropriate.

See http://gcc.gnu.org/bugs.html for instructions.

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.15.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.15.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

What is it, and how do you fix it?


texts: What sensor is used to judge transparency?

texts:
I want to create a system to separate between an aluminum can and a plastic bottle.

Both are lightweight, so I'm thinking of using the transparency property, meaning that the can is not transparent, but the plastic bottle is.

Will the light sensor work out?

Or would you suggest me another type of sensor I should use?


texts: OpenOCD with FT2232H on Arduino Mega (ATmega2560)

texts:
I want to do on-chip-debugging on an Arduino Mega.
According to its datasheet, the ATmega2560 chip supports JTAG. (IEEE 1149.1 compliant)

Can I use a generic FT2232H interface to do on-chip-debugging on this?

How would a OpenOCD config file look like for this purpose?

Thanks in advance!


texts:
Why such horrible Arduino's Mega PWM doesn't work??

Below is my code.

I try to set Fast PWM 8-bit to dim and light up a LED connected to OCR1A Pin. I try to do it in C language, completelly without Arduino's lbraries and it doesn't work at all.

I'm working with documentation and the code seems me to be correct. Almost the same code worked on ATmega8 and ATmega16 (obviously, with special setting for those special ATmegas) but this one doesn't.

The comments in this code point out, that I tried to use few other flags to  check if it work with some of another settings.

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

//Anode of LED connected to OCR1A (digital pin 11)
#define LED (1<<PB5)

int main()
{
  DDRB |= (1 << LED);

  //FAST PWM 8-bit, set OCR1A at the Bottom
  TCCR1A = (1 << COM1A1) | (1 << WGM10);    // | (1<<WGM11) | (1<<COM1A0)
  //Prescaler :1024
  TCCR1B = (1 << CS12) | (1 << WGM12);     //| (1<<WGM13); //Presc :1024  (1<<CS10) |
  //Enable to interrupt Compare Match A
  TIMSK1 = (1 << OCIE1A);

  uint8_t i;

  sei();

  while (1)
  {
    for (i = 0; i < 255; i++)
    {
      OCR1A = i;
      // _delay_ms(5);
    }

    for (i = 255; i > 0; i--)
    {
      OCR1A = i;
      //_delay_ms(5);
    }
  }
}

}


texts:
I am trying to create an array of structs that contain pairs of Strings and Callbacks the problem I am having is assigning the callback function. I have the following code:

#define UI_ROUTINE_ITEMS 10

struct MenuItem{
    String label;
    typedef void (*callback)();
};

class MenuSystem{
   MenuItem routineMenu[UI_ROUTINE_ITEMS];

   MenuSystem(){
      routineMenu[0] = {"Test", &Test::TestCallback};
   }
}

class Test{
   void TestCallback(){
      Serial.println("Callback called");
   }
}

When I try to compile this I get:

error: no match for 'operator=' (operand types are 'MenuItem' and '<brace-enclosed initializer list>')

I know this is a Syntax issue I just can not figure out how this should be done. I have looked at several examples but I can't figure out how to do this with Classes without using free/malloc, what am I doing wrong?

EDIT

I finally got this working, the problem was that the function that I was trying to call was not static and the declaration in the structure was not quite right. Below is the corrected example:

#define UI_ROUTINE_ITEMS 10

#include <Arduino.h>

struct MenuItem{
    String label;
    void (*callback)(void);
};

class MenuSystem{
   MenuItem routineMenu[UI_ROUTINE_ITEMS];

   MenuSystem(){
      routineMenu[0] = {"Test", &Test::TestCallback};
   }
}

class Test{
   public static void TestCallback(){
      Serial.println("Callback called");
   }
}


texts: Best way to implement score board logic using Arduino and Shift Registers?

texts:
I am from a mobile development background and very new to Arduino. I am trying to make an electronic cricket score board. The logic is simple.

Score - 888 (3 Digits) - I have implemented this logic using shift registers.  Three pin used from Arduino Uno and this is working fine.

Overs - 88 (2 Digits) - Need to find a best way to implement it

Wickets - 8 (1 Digit) - Need to find a best way to implement it

Now I need to add Wickets and Overs to the logic. I think there are two ways to do it.

One is passing data from Score shift registers. I think this way is a bit complicated in logic level. But if this is a good way, then great.
The other is, connect to Arduino Uno pins directly rather than getting information from score shift registers.  There are only few pins.

Please Note: I need to print this design in PCB

This might be a basic question. But I would like to the know which way is efficient, and its advantages. If both are not, I would like to the know the best one.


texts: Platform-independent functions for FastPWM?

texts:
I learned from answers here that pinMode(0, OUTPUT) is a platform-independent equivalent of DDRB = 1<<DDB0, on the ATTiny85.

Are there platform-independent functions for the following?

TCCR0A = 2<<COM0A0 | 2<<COM0B0 | 3<<WGM00;
TCCR0B = 0<<WGM02 | 1<<CS00;
TCCR1 = 0<<PWM1A | 0<<COM1A0 | 1<<CS10;
GTCCR = 1<<PWM1B | 2<<COM1B0;

Explanation of above code here. These calls enable FastPWM.

I checked the Arduino API reference, but not sure which are the equivalent to above. How to determine?


texts: Is there an similar function in AVR-libc/Arduino C++ to mmap()? I'm looking for a way to place machine code in memory at runtime and make it executable.


texts: Soft wdt reset error on NodeMCU (ESP8266)

texts:
I am getting error on Serial monitor Soft WDT reset. I decoded the error code also and found the following stacktrace.
I am using SIM808 module and DFRobot_sim808 as the library.

0x4010030d: millis at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/core_esp8266_wiring.c line 180
0x401003b9: __digitalWrite at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/core_esp8266_wiring_digital.c line 82
0x40202863: sim808_wait_for_resp(char const*, DataType, unsigned int, unsigned int) at Documents\Arduino\libraries\DFRobot_SIM808-master/sim808.cpp line 172
0x402027a4: sim808_send_byte(unsigned char) at Documents\Arduino\libraries\DFRobot_SIM808-master/sim808.cpp line 118
0x402028ce: sim808_check_with_cmd(char const*, char const*, DataType, unsigned int, unsigned int) at Documents\Arduino\libraries\DFRobot_SIM808-master/sim808.cpp line 191
0x402025dc: DFRobot_SIM808::init() at Documents\Arduino\libraries\DFRobot_SIM808-master/DFRobot_sim808.cpp line 63
0x402024c1: setup at G:\Development\ESP8266\SIM Module\sim_module/sim_module.ino line 41 (discriminator 1)
0x40203248: loop_wrapper() at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/core_esp8266_main.cpp line 122
0x40100e8d: cont_wrapper at AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266/cont.S line 81

I tried to find solution for the same everywhere but none found it. But the same code I am trying on arduino it works but not for ESP8266. I dont have long waiting loop(). But still it gives me error.
Below is the code for the same
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define PHONE_NUMBER "********"

#define MESSAGE  "hello,world"

#define PIN_TX D1
#define PIN_RX D0

SoftwareSerial mySerial(PIN_RX, PIN_TX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

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

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB
  }
  while(!sim808.init()) {
      delay(1000);
      Serial.print("Sim808 init error\r\n");
  }
  Serial.println("Sim808 init success");
  Serial.println("Start to send message ...");

  sim808.sendSMS(PHONE_NUMBER,MESSAGE);
}

void loop() {

}


texts: When does the pulsein() function start counting?

texts:
I have an Arduino Pro mini 3.3V, 8 mHz and I want to use the pulsein() function for a low-going pulse. My question: Does the timer start when the function senses a LOW on the input pin, or when the function senses a high-to-low transition, or either?

Code snippet:

pinMode(3,INPUT); // Signal input to Arduino from pin 2 on LM339  - D3
int pwindow = 6000; // Maximum timeout value for pulsewidth
long pcounterA = 0; // Unfiltered Pulse Width of Channel 1
pcounterA = pulseIn(3,LOW,pwindow);
Serial.print(pcounterA);

Thanks for any help.
JT


texts: Didn't have MAC address on Wiznet based ethernet shield (cloned)

texts:
My Ethernet shield dont have any MAC address, please tell me how to find the MAC address, I'm stucked! Here is the link from where I bought the Ethernet shield.
http://www.amazon.in/gp/product/B00AXVX5D0?ie=UTF8&at=&force-full-site=1&ref_=aw_bottom_links


texts: Can't make ultrasonic sensor work with motor controller

texts:
I just started using Arduino Uno, I can't get the ultrasonic to work ,with motor controller board, the output value is always zero.

Just to make sure I'm talking about the correct stuff:
I used this guide to try to make it work (look at the picture how did I connect the parts).

And this is my code:

#define trigPin A4//Attach Trig to port 8
#define echoPin A5//Attach Echo to port 7
#include <AFMotor.h>
//SMARS Demo 2 with Line sensor

AF_DCMotor R_motor(2); // defines Right motor pin
AF_DCMotor L_motor(1); // defines Left motor pin

int lmotorpin1 = 3;
int lmotorpin2 = 5;
int rmotorpin1 = 6;
int rmotorpin2 = 9;
int distancecm = 0;
//const int trigPin = 18;
//const int echoPin = 19;

// defines variables
long duration;
int distance;
void setup() {

  Serial.begin(9600); // sets up Serial library at 9600 bps

  //changes the following values to make the robot drive as straight as possible
  L_motor.setSpeed(200); // sets L motor speed
  R_motor.setSpeed(140); // sets R motor speed

  R_motor.run(RELEASE); //turns L motor on
  L_motor.run(RELEASE); //turns R motor on

  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
}

void loop() {
      Serial.println(trigPin);
    Serial.println(echoPin);
  distancecm = mdistance();
  if (distance < 5) {
    L_motor.run(BACKWARD); //moves motor L Forward
    R_motor.run(FORWARD); //moves motor L Forward
//    delay(1000);
//    L_motor.run(FORWARD); //moves motor L Forward
//    R_motor.run(FORWARD); //moves motor L Forward
//    delay(1000);
  }
  else {
    L_motor.run(FORWARD); //moves motor L Forward
    R_motor.run(FORWARD); //moves motor L Forward
  }
}

int mdistance()
{
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  Serial.print("Duration: ");
  Serial.println(duration);
  // Calculating the distance
  distance = duration * 0.034 / 2;
  // Prints the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.println(distance);
}

As you can see I tried different pin numbers but it always 0 ....

what do you think can be wrong?

The motors work.
Motor Controller: KEYES L293D Motor Control Shield
Sensor: Ultrasonic Ranger V2.0


texts: How to detect V-SYNC on the SparkFun MicroView?

texts:
Is there a way to detect the start of the OLED screen refresh cycle (V-SYNC) on the SparkFun MicroView? There is no code for this functionality in the Arduino library; in fact it looks like the Arduino library is only set up to send data over SPI to the display, and not receive any data/status back.

Do you know how to access the internal state of the OLED screen directly, by polling some kind of status bit over SPI?

The only datasheet I can find of this OLED screen does not have SPI command details.

Update: here's a movie taken with an iPhone on "slo-mo" video, showing a full screen (all pixels on). There is clearly a screen refresh going on, which interlaces with the video frame rate.