texts: Arduino Yun restarts or stalls during operation

texts:
I have an Arduino Yun that I need to connect to a machine to detect whether the machine is working or is stopped.

The signal used as a flag for such behaviour is basically the presence or absence of current in one of the motors that work when the machine operates. The voltage going through the motor is 220VAC. So I figured I could use a standard AC to DC converter like the one used to charge the phones (since those converters usually take 100~240V at 50/60Hz and output 5V with 1A) and connect that to one of the digital ports in input mode. Then I would know if the machine is working or not if such pin is in HIGH state or LOW state respectively.

Well, this works up to certain point. For some reason, the YUN stalls or resets itself while the machine is operating. I've checked the voltage and even used a voltage regulator to make sure it doesn't exceed the 5V. I even connected the signal to an Analog pin and measured the input and it never read more than 4.9V. So I guess my question is, what might be causing this behaviour and how could I avoid it. I suspected it was a voltage/current spike but with the voltage regulator and the resistors I added before passing the signal to the Arduino I though the issue should be solved but the issue persists.

Attached is an image of the power adapters I'm using to both feed the arduino with current and convert the signal that goes to the pins to DC.

Basically, I know that the arduino stalls because it closes the telnet session I am using to monitor the values read by the pins and because the USB let goes off. Normally the arduino will have the USB and the ON leds on but once the issue happens it turns the USB led off and in some boards it turns on the WAN led on.

Interestingly enough, it seems that the issue happens when the machine is stopped (LOW voltage) and is preparing to start working.

Just as a note. I've tried different Arduino Yun boards and all have the same behaviour so I don't think it's a matter of the board being broken. Resetting the board allows it to continue reading the signal but eventually it stalls again


texts: Why does Ethernet.begin() require a MAC address when WiFi.begin() doesn't?

texts:
I am working on an Arduino application which is dependant on a certain library. This library uses the Ethernet class for network communications, but ideally, I would like it to be wireless (I have both an Ethernet and WiFi shield available for testing).

When working on replacing the Ethernet functionality of the library with the corresponding WiFi functionality, I noticed that the Ethernet.begin() function requires a MAC address while the WiFi.begin() doesn't (it instead accepts SSID and password, among a couple of other things).

As both come shipped with a MAC address sticker on them, I couldn't really figure out why this is the case (and if I need to supply the MAC address found on the WiFi shield in some other fashion).

Why is this the case?


texts: Throughput and BER test with nRF24L01+ radio and Teensy microcontroller

texts:
I am trying to modify the example given in the this page to a basic throughput and BER test with two nRF24L01+ and Teensy 3.0 modules.

I want to modify the nrf24l01_send_string example in a way that I can remove the powerUp powerDown and delay and transmit the next packet purely based on the ACK received from the receiver. The problem is RF24 class does not seem to have a method to transmit ACK (not ACK+Payload) and the datasheet does give any information on the structure of the ACK message. The example works when powerUp and powerDown are removed, but I need to modify it to measure throughput by removing the delay.


texts: Possible to have different torque levels on MG966R servo with Rotary Potentiometer?

texts:
I want to apologise first and foremost, and say that I am very new to Arduinos!

I wanted to control the torque on a MG966R servo so that I can separate it into 4 different torque levels. I read that by adjusting the input voltage, you can run the servo at different speed, hence, i was thinking if I could incorporate a rotary potentiometer to adjust the speed of the servo.

Also wondering if changing angle stepsize of MG966R servo will affect torque in anyway?

Thanks all!


texts: Basic C++ programming, how to pass constructor argument into class?

texts:
I'm having some programming problems.

So here's what's happening:

In my .ino file, I have a tft variable which holds the connection to a LCD. I want to make a class which can either automatically access that tft class contained in the .ino, or pass it into the constructor when it's created; so basically:

// assuming this is the .ino:

TFT_ILI9163C tft = TFT_ILI9163C(cs, dc, rst);

MenuClass *menu = MenuClass();
menu->init("Example", tft); // this should work and "menu" should now have access to the "tft" variable

Here's my Menu.cpp:

// Menu class

#include "Menu.h"
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>

String menName = "Unnamed";

void MenuClass::init(const String name)
{
    menName = name;
}

String MenuClass::getName() {
    return menName;
}

void MenuClass::draw() {
    tft.setCursor(2, 2);
    tft.print(menName);
}

MenuClass Menu;


texts:
I'm trying to send a char [] through an NRF2401 but the radio.write () method always return 0. Check that msg contains the message read from str.

#define TAM 50

RF24 radio(9,10);

const uint64_t pipe = 0xE8E8F0F0E1AA;

char  msg[TAM];

void setup() {

  Serial.begin(9600);

  radio.begin();

  radio.openWritingPipe(pipe);
}

void loop() {
    if(Serial.available() > 0){
      String str = Serial.readString();
      str.toCharArray(msg,TAM);
      if(!radio.write(msg, TAM)){
        Serial.println("Message not send");
      }
      else
        Serial.println(msg);
    }
}

What am I doing wrong?

Edit1:
What I have noticed, is that the first time I was allowed to send it but the others no longer.

Edit2:
Remove the keyboard input by a char [] and sent it to without problems. Why can this be? Anything else happen when I make a keyboard entry?


texts:
How does one modify the Bluetooth settings, like services or pincode, on a light blue bean?
Ps I'm on Android

http://legacy.punchthrough.com/bean/ if you don't know what I'm talking about


texts: Repeatedly checking multiple "if" statements

texts:
This code is part of a long code for a robot that is both obstacle-avoiding and remote control. I am trying to get the code to check both "if" statements when the code number FF807F is received from an IR remote. When the code number is received
the program checks both "if" statements and carries out the one that is true. I want the program, once it has finished carrying out the true "if statement, to check both "if" statements again.

void loop () {
if (My_Decoder.value==0xFF807F){
 if (cm<6)
 {
  motor_stop();
  digitalWrite(backlights, HIGH);
  delay(2000);
  motor_backward();
  digitalWrite(backlights, HIGH);
  Serial.println("backward");
  delay(2000);
  motor_stop();
  digitalWrite(backlights, HIGH);
  delay(900);
  motor_right();
  digitalWrite(backlights, LOW);
  Serial.println("right");
  delay(1000);
}
if (cm>6)
 {
  motor_forward();
  digitalWrite(backlights, LOW);
  Serial.println("forward");
}
}
}


texts:
I need to read a sensor every five minutes, but since my sketch also has
other tasks to do, I cannot just delay() between the readings. There
is the Blink without
delay tutorial
suggesting I code along these lines:

void loop()
{
    unsigned long currentMillis = millis();

    // Read the sensor when needed.
    if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
        readSensor();
    }

    // Do other stuff...
}

The problem is that millis() is going to roll over back to zero after
roughly 49.7 days. Since my sketch is intended to run for longer
than that, I need to make sure the rollover does not make my sketch
fail. I can easily detect the rollover condition
(currentMillis < previousMillis), but I am not sure what to do then.

Thus my question: what would be the proper/simplest way to handle the
millis() rollover?


texts:
Good evening!

I am quite new with Arduino but not in programming. Still, I have already done some programs with few leds.

I was just wandering how to create a circuit and a program that would play the "happy birthday" song with the following materials:

I have a breadbord and some wires.

Else, do you have some links where I could start learning how to play music with it?


texts: Connect arduino nano and ESP32 with I2C on the GPIO7 and GPIO8?

texts:
I made a mistake connecting SD0 (GPIO7) and SD1 (GPIO8) with the SDA and SCL on my arduino nano. I got confused with GPIO21 and pin21 and GPIO22 and pin 22!

Since I made a PCB prototype, I would avoid to add some wires and cut the traces, so I would ask if I could use these pins (GPIO7 and GPIO8) as SDA and SCL.

If the answer is affirmative, using Arduino library how could I assign them?

Wire.begin (7,8)?

Another question, I would use a dedicate 2x4.7K pull up resistors. On the arduino side I wrote:

digitalWrite(SDA, 0);
digitalWrite(SCL, 0);

It is correct to do the same thing on the ESP32 side?

Update November 01:
After the question from Majenco I think I need more help for the I2c setup.

I designed the PCB having in mind that the esp32 was 5V tolerant, so at the moment I pull-up the SDA, SCL from the 5V that I input in the esp power pin. Note that this 5V doesn't come from the Nano due to the high current required by the esp. I take my 12V power supply input and regulate it to 5V with a 7805, only dedicated to the esp (I know, a lot of dissipation! In the next PCB version I have to change the things, having in mind that I need both 12V and 5V in my circuit).

Now, I read that the esp32 is not 5V tolerant. In order to avoid level shifter can I pull up the SDA and SCL from the 3.3V line (the arduino 3.3V or esp32 one?)?

I would use the esp32 as master.

Thanks.


texts: issue with DVD drive stepper motor for 3d printer

texts:
Short version:
1: Is it possible to run just the stepper motors (pulled out of a DVD Drive) using either a 5v 2a mobile charger or a 9v battery plugged into the Ramps 1.6 power input?
2: what could be a possible issue for "echo: busy: processing" message on pronterface. I believe its not an issue with the extruder or bed temp reading.
Long version:
A year ago I tried building a 3dprinter using some DVD stepper motors.
I was using two stepper motors, two a4988 stepper motor drivers, ramps 1.6, and Arduino mega.
I didn't get anything else since I was not sure if I will be able to make a functional printer properly and didn't want to pointlessly invest in the hardware.
For power, I was using a power bank with 2A 5V output.
The steppers were working fine as expected.
I kinda dumped the project since i got an ender 3.
Recently I decided to get back to it just for fun, tho this time I was using a different power source.
It was a power adapter to charge cellphones and it had the same output. However this time none of the stepper motors moved. I tried everything, i kept getting "echo:busy: processing" on pronterface every time I tried to move an axis.
Im assuming the steppers could be busted but i don't have a lot of ways to test it.
So
my questions are

Can i use a 9v battery to test out just the x and y axis or do i need a 12v smps?
can anyone explain wat could be the possible issue for echo message. I've tried to add/remove jumper wires to the extruder and bed temp pins (t0,t1 pins), so I'm assuming this cant be the issue.
If anyone has ever made a 3d printer using similar stuff, can u share your experience, and wat challenges u faced

also, sorry for sounding insanely dumb, and asking such trivial questions instead of trying them out.
I'm an absolute beginner with arduinos and i live in the middle of nowhere so amazon is my only friend when i need something, better to ask here instead of waiting for a week for a mere battery :)
Thanks


texts: Broken Arduino Uno, works over USB but cannot take DC in

texts: My Arduino Uno (r3) board seems to be broken. It can still be powered over USB, and can store/run code properly, but the DC power in system appears to be crippled. I'm not entirely sure what happened, but I was most likely being careless with the power in and the vin pin. I'm not sure what component(s) are broken, but when I plug in 12v into the barrel connector, the uno doesn't power on. I can read about 0.6 volts from the 5 volt pin, and at some other locations on the board. Besides the 0.6, the only other voltage I read is the 12 volt, although it is slightly lower than the power supply, which outputs about 12.2 volts. How can I go about fixing this? Or is it even worth it?


texts: What the two yellow cables as you can see in the picture do not know?


texts: Why is their need of response time needed in esp8266 AT commands?

texts:
I am writing an AT commands firmware for esp8266 via connecting it to atmega2560.
Now the question is how will I come to know the response time for AT commands for writing its firmware to read the response?
in fact prior to this thought, the question comes why is their need of response time in AT commands?
does response time concept is there in all modules where AT commands are used like gsm modules, HC05,etc.


texts:
I have four bistable solenoid valves that I want to control using Arduino. They use 24V and are pneumatic, in other words they will be controlled through the Arduino and air. I have looked at a lot of tutorials and have got a lot of useful info, but still can't figure it out. I have been trying to make it work with one valve before I start making all four work. I have been using an 1R Ohm resistor and a transistor (I don't know what kind). I have been trying to make it work only using the vin function on the Arduino, but I think I might need to use an external power source for this to work. Can anybody help me in any way? Maybe draw a schematic of how I can set it up?
Thanks in advance.
Edit: I just found out that the transistor is a BD175. The valves are pneumatic 5/2 bistable valves controlling a double working cylinder (one that works both ways). I am trying to build a mini overhead crane where three of the cylinders are double working ones and one is a claw that is also double working, but they're all controlled by the same bistable 5/2 valves


texts: Condition in a while loop not updated on my mkr1010

texts:
I am using a server-client system where i send data from the server to the client to turn on a led (the onboard led). Led must be turned off using digital input (labeled 7 on the connector).
I use therefore a while loop that checks the value of the input (button press). As long as value is not equal to LOW the led remains on (i use also a second led on pin 13 as doublecheck). I assume that the while loop will be left once i press the button, unfortunately this doesn't happen. The result of the condition seems not updated (remains HIGH).
I measured the voltage on the input when pressing the button and it goes from 3.3V to 0.0V so hardware seems to be OK.
From my undestanding the while loop is always (before each loop) checking the condition ? why doesn't this happen here ? did i do something wrong ?
I must use a while because i never know in advance when the button will be pressed.

this my code :

#include <SPI.h>
#include <WiFiNINA.h>
#include <utility/wifi_drv.h>
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)

//int keyIndex = 0;            // your network key Index number (needed only for WEP)

const int buttonPin = 7;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin
int buttonState;         // variable for reading the pushbutton status

int status = WL_IDLE_STATUS;
IPAddress ServerIP(192,168,0,157);
WiFiClient client;

int i;
String response;

void setup() {

  WiFiDrv::pinMode(25, OUTPUT); //GREEN
  WiFiDrv::pinMode(26, OUTPUT); //RED
  WiFiDrv::pinMode(27, OUTPUT); //BLUE

 pinMode(buttonPin, INPUT);
 pinMode(ledPin, OUTPUT);

  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
   ; // wait for serial port to connect. Needed for native USB port only
  }
  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
  Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
    delay(10000);
  }

    // you're connected now, so print out the status:
  printWifiStatus();
}

void loop() {

if (client.connect(ServerIP, 23)) {
  client.print("90");
  String response = client.readStringUntil('\n');

  Serial.println(response);

if (response == "9") {
  buttonState = digitalRead(buttonPin);
 // Serial.println(buttonState);
  while (buttonState != LOW){
    // turn LED on:
    digitalWrite(ledPin, HIGH);
     WiFiDrv::digitalWrite(25, 255); // for full brightness
     Serial.println(buttonState);
  }
  digitalWrite(ledPin, LOW);
  WiFiDrv::digitalWrite(25, LOW); // for full brightness
        }
  }

  client.stop();
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
 Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

thanks a lot for helping me out !


texts:
I've set up a Yun before to use the handshake line on pin 7 (thanks to this great forum post) and now I have a new project that I want to do something similar with the Tian. Based on the schematic, it's a similar idea: set the output, mark the output low. But so far I haven't been able to get it working. Anyone know how to adopt the following command from /etc/rc.local to the Tian?

# Added section to set the handshake line.
# GP19 is connected to D7 of the 32U4 processor.
# This requires setting GP22 high to enable the U7 level shifter.
# This GPIO is already exported.
# Then GP19 needs to be exported, set to output, and finally brought low.
echo 1 > /sys/class/gpio/gpio15/value
echo 21 > /sys/class/gpio/export
echo "high" > /sys/class/gpio/gpio21/direction
echo 0 > /sys/class/gpio/gpio21/value

This code is what I'm using now: it's the forum poster's text with my updates for the Tian.


texts:
I am stuck with this motor shield. All I have is the shield. No documentation available online, nothing.

I need to run two motors off this thing and I only have a few hours to figure out how this works.

Can anyone point me in the right direction..?
Like how to control the 2 motors that I have from it (if they could be plugged into the pins right on top of that green thing with screws, that would be great) and where to plug in the power supply?

I've seen a lot of weird motor controllers for Arduino, this one I just can't figure out.


texts: which is the number of bits in a float variable

texts: Since the maximum value of a float variable is 3.4028235E+38, shouldn't it represented with 128 bits instead of 32? (2^128=3.4028235E+38).


texts: Compiling with -flto and -nostartfiles results in no program at all

texts:
Towards developing my own bootloader I've stumbled over an issue with avr-gcc. I am trying to compile my code with the compiler flags

-flto          #to enable link time optimization
-nostartfiles  #to omit the interrupt vector table

My bootloader consists of multiple files which are used depending of compile flags. All the sources are being compiled and linked while the code path only leads to some portions of them. So I wanted to get rid of the dead code and -flto (being a newer development) creates a much smaller machine code size than -ffunction-sections -fdata-sections with -Wl,--gc-sections -Wl,--print-gc-sections.

But when it comes to further reducing the machine code size by removing the interrupt vector table using -nostartfiles, the complete code gets optimized away leaving me with a zero byte output.

Has anyone experienced the same issue with that compiler flag combination?


texts: What is the proper way to make library pin mappings configurable?

texts:
I am working with some libraries that provide APIs for interacting with specific hardware chips (that makes these drivers?).  However, different custom boards or shields will have the chip mapped to different pins meaning the library needs to be modified for each case.  Needing to modify the library does not work well with the Arduino IDE Library Manager.

Are there preferred/recommended patterns for exposing this configuration so that the library itself does not need to be modified every time?

Here is an example where it is documented which part needs to be changed to match the pin layout of your board.


texts:
I am really interested in IoT (enthusiastic noob) and I would like to use the arduino board. Here are the steps according to me, with my queries:

User goes to example.com/arduino_switch
Interacts with an HTML form to toggle an action
Sends the data over the Internet (This is the part I have problem understanding)
Arduino receives the data point (how can we do this? polling a url or can we actively send it)
performs the action (easy to do for me)

Any and all help will be appreciated, even if its just pointing me to the right resources.


texts: Powering a 6-12V motor using a lead acid 6V battery with 6Amps of current?

texts: Hi I'm using a adafruit motor shield v2 and I need to power a DC motor 6-12V but I'm not sure if my battery will be okay for the shield. Will it burn the shield? I'm going to be using 6V so it should draw less current?


texts: Playing Audio from SD - Get VU, or audio waveform

texts:
I am using the library SimpleSDAudio to play a song from my SD card to an op-amp later in the circuit. I would like to take a sample from the audio pin (possibly with a Analog read) to power some visualizations (VU, etc.), although I am getting some unexpected readings off the audio pin.

I tried to bias the audio using this post, but got the same results.

I'm not sure if I am headed in the wrong direction here, any help would be amazing.

#include <SimpleSDAudio.h>
int ReadPin = A0;
int AudioValue = 0;

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

  Serial.print(F("\nInitializing SD card..."));

  if (!SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER)) {
    Serial.println(SdPlay.getLastError());
    while(1);
    } else {
    Serial.println(F("Wiring is correct and a card is present."));
  }

  Serial.print(F("Looking for THRILLER.WAV... "));
  if(!SdPlay.setFile("THRILLER.WAV")) {
      Serial.println(F(" not found on card! Error code: "));
      Serial.println(SdPlay.getLastError());
      while(1);
  } else {
     Serial.println(F("found."));
  }

  Serial.print(F("Playing... "));
  SdPlay.play();

}

  void loop() {
    AudioValue = analogRead(ReadPin);
    Serial.println(AudioValue);
    delay(50);

}

My expected output of sampling the output from A0:


texts: Wrong characters received with Bluetooth Mate Gold using Software Serial

texts:
I have a Bluetooth device from Sparkfun which I would like to use with the Arduino Mega. If I connect the module via the hardware serial pin everything works fine but when I use other pins like 12 and 13 with SoftwareSerial, the communication doesn't work as expected.

THE CODE

#include <SoftwareSerial.h>

int bluetoothTx = 12;
int bluetoothRx = 13;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
  //Setup usb serial connection to computer
  Serial.begin(9600);

  //Setup Bluetooth serial connection to android
  bluetooth.begin(115200);
  bluetooth.print("$$$");
  delay(100);
  bluetooth.println("U,9600,N");
  bluetooth.begin(9600);
}

void loop()
{
  //Read from bluetooth and write to usb serial
  if(bluetooth.available())
  {
    char toSend = (char)bluetooth.read();
    Serial.print(" Receiving: ");
    Serial.println(toSend);
  }

  //Read from usb serial to bluetooth
  if(Serial.available())
  {
    char modeS = Serial.read();
    Serial.print(" Writing Blu: ");
    Serial.println(modeS);
    bluetooth.print(modeS);
  }
}

I'm using an Android App (BlueTerm) to test the communication.

Here is what I get when sending a letter from Android to Arduino.

 Receiving: ÿ
 Receiving: ÿ
 Receiving: ÿ
 Receiving: ÿ
 Writing Blu: d
 Writing Blu: d
 Writing Blu: d

I'm not able to receive anything from the Arduino.

I've tried decreasing the baudrate but nothing changed. Do you have any advice?

Update

I have tried without the following lines but nothing changed... It seems that the module can be used only with the hardware serial pins 0 and 1... It's a shame

bluetooth.print("$$$");
delay(100);
bluetooth.println("U,9600,N");
bluetooth.begin(9600);


texts: Extra "zero" displayed on LCD when integer sent from PC to Arduino through serial port

texts:
Every time I send an integer from computer to Arduino an extra zero is displayed on the LCD connected to Arduino. I don't know the reason. Why?

Here is the code:

#include <LiquidCrystal.h>

int en = 2, rs = 3, d4 = 7, d5 = 6, d6 = 5, d7 = 4;
int a;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);

void setup() {
    Serial.begin(9600);
    lcd.begin(16,2);

}

void loop() {
    Serial.println("Enter a number");
    while(Serial.available()==0){}
    a=Serial.parseInt();
    lcd.print(a);
}

The result is as follows:

Enter a number
When I enter the number 1
The result 10 is displayed instead of 1


texts: Regarding the USB port, what is the difference between Uno/Mega and the older boards?

texts:
I would like to know what the exact difference is between the Uno and Mega boards and the older boards (Duemilanove, Diecimila, etc.).  Why do I need to install a FTDI driver for the older boards, and not for the Uno/Mega boards?  I was in a class the other day, using the Nano, and the lecturer recommended the FTDI drivers. The Nano is a newer type board, so why does that require a driver? I've just discovered that the Nano is old tech from 2008, after reading Are there any reasons to pick Nano over Micro?

What is it about the Uno and Mega boards that don't require the FTDI to be separately installed?

I see that the Getting Started w/ Arduino on Mac OS X page states that the older boards use the FTDI chip. Does that imply that the Uno/Mega boards do not? If they do not, then what do they use?

I have a vague notion that some USB sticks, keyboards, mouse and other various USB devices may contain a driver within the circuitry/firmware(?) of the device, which when connected to a PC for the first time, can be used to install the driver without the PC needing to access the web for the driver. Is this what the difference is between the UNO/Mega and the older devices? If so, is it possible to modify, or flash the firmware of the older boards so that they can connect without the need for an FTDI driver?


texts: Switch MPU6050 to send SCL data through A4 and SDA through A5

texts: I have this MPU6050, and like most of the other MPU6050s, it is set up for SCL to be attached to A4 and SDA to be attached to A5. I have this shield on my Arduino Uno, which is configured for Sainsmart's (the company who made the shield) MPU6050, so the special MPU6050 pins are set up V, G, A5, A4, and my current setup needs V, G, A4, A5. I am using the built-in Wire library, I2CDev library, and the MPU6050 library. So I am wondering whether there is something in these libraries that define which pins it looks for my MPU6050 on, and if so how do I change it.


texts: Converting c string to integer to unsigned char

texts:
I'm Trying to grapple with types between two different libraries.
The gist is that I'm using the ArduinoWebsockets library to receive information coming from my api that I then want to render out to an LED matrix. An example message would look like this:
1
2
4
8
16
32
64
128

It's important to point out that the data here is a list of string version of numbers, not integers.
I.e. if you look at the binary version of 1 from the list it's actually 110001 which is the ascii code for the character 1.
This is because the message coming back from the websocket server is pulled out as a const char *.
The LED matrix function I'm calling has a signature of:
void Write_Max7219(unsigned char address, unsigned char dat)

So I need to send in the values as unsigned chars.
I want to:

parse this information line by line
convert the ascii character for the number into it's integer equivalent
pass the value to a different function to write the data to an LED matrix

And I'm not sure how exactly to do this. I've been grappling with the type const char pointer vs regular char pointer and how to properly parse the return delimited string.
Any help would be greatly appreciated!!
Clarification
Based on some of the comments I don't think I explained the reason I'm trying to do this conversion very well. Here's (hopefully) a better explanation:
The reason I want to convert it is because I'm not displaying the number character as a string, I want to use the binary representation to control the lights in a row of the matrix.
The number 1 or 0b00000001 would light up only the rightmost led on the 8 led row of the matrix.
The idea is that I could send over rows of numbers where each row corresponds to the row on the LED matrix.
e.g.
1   -> 0b00000001
2   -> 0b00000010
4   -> 0b00000100
8   -> 0b00001000
16  -> 0b00010000
32  -> 0b00100000
64  -> 0b01000000
128 -> 0b10000000

But the messages I get from the websocket server are coming through as the string representations of the numbers (ascii or utf) vs the numbers themselves, so I can't just pass the numbers into the function for the led matrix because the underlying binary is different.
The conversion is so that I can use the binary representation of 1 (0b00000001) vs the binary representation of '1' ( 00110001).
UPDATE AND RESOLUTION
So I've been on a big troubleshooting journey. When @ocrdu said:

BTW I would try to get the websocket to send the correct single bytes instead of string representations of numbers, if at all possible.

I thought "yeah, that's the real way of fixing it and understanding what's going on", so I started tracing the issue back. Without going into all of the detail it turns out that the problem I was having was actually starting at the test client.
I use firecamp and websocat as websocket client testing tools. I was trying to send the binary data via both tools, but when I dug in via Wireshark I found that the data in flight coming from the client itself was made up of the hex values for the encoded characters of the 1s and 0s.

After researching and asking a separate stackoverflow question I figured out a way of sending the actual binary data from the client, specifically printf.
e.g.:
 printf "\x01\x02\x03\x04\x05\x06\x07\x08" | websocat -b ws://localhost:3002

Now that this works I can start going back through the rest of my arduino code and have it parse the binary data directly instead of converting the encoded values to their binary counterpoints.
All of that said, I do appreciate all of the help. I may not have needed to do the conversions for this particular instance, but I want to get better with my C types, conversions, and general understanding so the knowledge gained here is still beneficial. Thanks everyone :bows:


texts: Complier overwrote bootloader doing a non-programmer upload

texts:
Got this when uploading (no programmer) to a MkrZero.

I had downloaded the board's toolset via the IDE earlier, and uploading smaller sketches worked fine.  On a larger, more complex project, got this:

Sketch uses 31000 bytes (11%) of program storage space. Maximum is 262144 bytes.
Atmel SMART device 0x10010005 found
Device       : ATSAMD21G18A
Chip ID      : 10010005
Version      : v2.0 [Arduino:XYZ] Dec 20 2016 15:36:46
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : none
Security     : false
Boot Flash   : true
BOD          : false
BOR          : false
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
done in 0.800 seconds

Write 31336 bytes to flash (490 pages)

[===                           ] 13% (64/490 pages)
[=======                       ] 26% (128/490 pages)
[===========                   ] 39% (192/490 pages)
[===============               ] 52% (256/490 pages)
[===================           ] 65% (320/490 pages)
[=======================       ] 78% (384/490 pages)
[===========================   ] 91% (448/490 pages)
[==============================] 100% (490/490 pages)
done in 0.234 seconds

Verify 31336 bytes of flash with checksum.
Verify successful
done in 0.075 seconds
CPU reset.

It sounds like it reset the chip completely... and Windows no longer sees a COM port from it via USB.
I've tried:
* The click and double-click on the board's reset button, including at the start of a new upload of a simple sketch
* Restarting the Windows machine
* Looking at device manager to see if any COM ports show up, even temporarily
* Same cable, same computer, different MKRZero - works

Main question:  What could there be in the project to have caused the compiler/loader to do this?    This is the 2nd time this project has triggered a reflash.   It does use the EEPROM API by A. Christian, but I've been able to use that before without this result.

2nd: Any other ways to recover the board?

Thank you for any guidance.


texts: Unusual behaviour when moving data to PROGMEM

texts:
I've got some working code with a definition that looks like this:

const unsigned char DynTextPositions[10][4][4] = {
    ...
};

Which is defined / referenced via a header:

#include <avr/pgmspace.h>
#ifndef DYNTEXTPOS_H
#define DYNTEXTPOS_H

extern const unsigned char DynTextPositions[10][4][4];

#endif

This data is being fed into a rendering function which draws lines based on the given positions. The data is read as follows:

float deltas[4][4];
// ...
deltas[n][k] = float(DynTextPositions[c+1][n][k] - DynTextPositions[c][n][k]) / 32.0;

As-is, this works just fine, as long as I've got my other scenes commented out. When I uncomment them, the combined data size seems to overflow the data segment. This is expected, because there's a fair bit of data, so I'm trying to move the DynTextPositions data into PROGMEM.

I've got PROGMEM working with some bitmaps, but it doesn't seem to work here. An example definition for a working bitmap is as follows:

PROGMEM const unsigned char ArduinoLogo[] = { ... };

However, as soon as I apply the PROGMEM attribute to DynTextPositions the rendering code seems to freak out - the positions appear to be all off-screen and completely wrong.

The only thing I can think of is that, for some reason, the data is either being considered signed rather than unsigned, or is getting corrupted along the way. Either that or the nested array is somehow being treated as a set of pointers.

Any idea why this might be?


texts: How to read incoming HEX values from Serial.read() method?

texts:
Brief description about the problem History
Communicating with a old VersaStat II used GPIB port but the GPIB ports PCI card stopped working but there was a another port 25 pin rs232 Serial communication port but even now, too bad computers are abending the Serial port luckily there is still virtual Blutooth COM port which can be used with a modern laptop so ESP32 microcontroller was selected to communicate with this device wirelessly (might later go for HC05 module etc.).
Fixing the voltage difference problem
Now there is a big problem the esp32 Serial uses +3.3 V or logic 1 &  0 V for logic 0 But in the rs232 port logic 0 is +3 V ~ +12 V and logic 1 is -3 V ~ -12 V  also ± 3V  undefined region. To overcome this problem I have used the following circuit with optocouplers.
Here is the circuit diagram

The following code was used to communicate with the device easy as seems
Code
#include "BluetoothSerial.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

BluetoothSerial SerialBT;
int speedsend = 9600;

void setup() {
  Serial.begin(speedsend);
  Serial2.begin(speedsend);
  SerialBT.begin("ESP32SERIAL");
  delay(500);
}

void loop() {

  if (Serial2.available()) {
//incoming data from the device
    int i = Serial2.read();
    SerialBT.write(i);
    Serial.println(i); // To check what is coming as output
  }
  if (SerialBT.available()) {
    Serial2.write(SerialBT.read());
  }

}

But I see no meaningful characters in putty (Bluetooth COM port) in Arduino Serial I see some numbers in HEX representation. Is this the way old devices communicate?
This link show how HEX numbers correlate with ASCII characters
https://www.rapidtables.com/convert/number/hex-to-ascii.html
How to fix this issue am I doing something wrong in here the circuit parameters etc.
Communication Example with device
For a start the ID command should give a number as 2532 according to book after the conversion it gives me 32 32 34 32 0 0 , 2242 looking at the Arduino Serial numbers with the help of the converting web site shown in above url. That's how I noticed It gives me HEX numbers.
Here is the PDF rs232c Interface section PDF the original Book came with ID command page too.
https://drive.google.com/file/d/1BHhIsloF4voMxoFeSlz1GsjwfgHwgsPJ/view?usp=sharing
Another book looks same but not from the book came with
https://drive.google.com/file/d/1z0NUOe17SpVYTIBfEE8s0EKStfLKKv_-/view?usp=sharing


texts: Sending multi-byte data over I2C between different processors

texts:
I have been attempting to read data from an ATTINY84 via an ESP8266. Both are programmed via the Arduino IDE, though as PlatformIO is a proxy for that, I'm not certain what version of the ATTINY core is in use.

I have both devices connected to the I2C bus, with the Arduino as a slave.
The ESP sends a code requesting a particular type of data, then calls Wire.requestFrom() to get 8 bytes of data. I am concerned over both my implementation and about potential endian-ness issues (even if it should turn out not to be an issue on these two particular devices, I'd like to know my future options).

The ATTINY code is a complex function that is called when there is a request (and the right option code, but that's probably not very relevant). It writes eight bytes using Wire.write after uncompressing them from the relevant arrays. (I have a lot of ADC data that technically should not fit in RAM.)
Since this is is a callback function or possibly an interrupt, do I need to be concerned about data corruption if the code is too slow to write the values onto the bus? I have to imagine it's trying to read them even as it writes. I can also provide code snippets if it would help.

I am also unsure if I am running into Endian-ness issues by using bitshift to grab the 2 and 8 bits from the ADC return value. Would this always give me the correct values, or does the C++ compiler (as I assume it does not) simply refuse to handle differences between the data order?
Specifically, if I shift a uint16_t (or any non-trivial datatype) right by 8 bits, and mask out the bottom 8 with &0xFF, do I always get the second-least-significant (in this particular case, high) byte, or can the compiler produce alternate outputs based on byte order?

Does Arduino have an equivalent of network byte order (or does Wire automatically do so for its overrides of the functions) that I can get around this potential issue with?


texts: How do I go about building a backend for my Arduino device?

texts:
I am new to Arduino, but I am putting together a project in which the Arduino Uno has multiple sensors (temperature, humidity, etc) collecting data. Right now all it is currently going to do is get the data and send it over to https://plot.ly/ to save and view the data.

Using this: http://tronixstuff.com/2014/01/21/online-data-analysis-arduino-plotly/

What I want to do is build a backend application that will instead receive this data and actually do something with it. It would use users, and all the usual backend functionality. So either some good PaaS that someone can recommend, and/or resources of what to use to build out an API that can "talk" to an Arduino. Perhaps Python or Node (NO PHP), and it should do it via Wifi to connect to the internet.

Thank you


texts: What are the connectors used in the arduino mega?

texts: I am trying to build a shield for an arduino mega.For that i need to know the type of the female connectors that are soldered in the pins of the arduino mega in order to choose the correct male connectors.


texts: Send numbers to arduino via serial port using python

texts:
I have a file with numbers called fginputs.txt. For example it could be something like this:
4958
4154
4154
4154
4154
4154
4154
4154
4154
4154
4154
4154
4154
4154
4154
4154
4154
4958

I want python to send each number to arduino via serial port. After each number is received, arduino should print back an acknowledgment number, indicating that it got a valid number, and then store that number in a dynamic array, because I could create larger files. When there are no more numbers left, send a '-1' to finish transmission.
Here's my arduino code:
// save some unsigned ints
uint16_t SIZE, *inputList, cont = 0;
boolean inputsReady = false;

void setup()
{
 // initialize serial communication at 9600 bits per second:
 Serial.begin(9600);

 //free dynamic array memory
 free(inputList);
 //counter for how many numbers I've received starts at 0
 cont = 0;
 //This is true when there are no more numbers to receive, meanwhile false
 inputsReady = false;
 setupInputList();
 }

/* If there's not enough space, resize the array by one unit and store the number
   */
void growAndInsert(int currentSize, int newInt){
    if(currentSize > SIZE)
        inputList = (uint16_t *)realloc(inputList, (currentSize + 1)*sizeof(uint16_t));
    inputList[currentSize] = newInt;
}
/**
  init inputList with 100 blocks
 */
void setupInputList(){
  SIZE = 10;
  inputList = (uint16_t *)malloc(sizeof(uint16_t) * SIZE);
}

void clearBuffer(){
while(Serial.available() > 0)
    Serial.read();
}

/**
Listens in serial port for an integer that represents a new input and returns it.
If it doesn't get anything useful from serial, return 0
*/
  int getNewInputFromSerial(){
   if (Serial.available() > 0) {
    delay(100);
    // look for the next word
    int cmd = Serial.parseInt();
    clearBuffer();

    if(cmd == 4958)
        Serial.write("4");
    else if(cmd == 4154)
        Serial.write("5");
    else
        Serial.write("0");
    return cmd;
   }
  return 0;

}

void loop()
{
     if(!inputsReady){
        int newInput = getNewInputFromSerial();
        if(newInput == 0)
            return;
        if(newInput != -1)
            growAndInsert(cont++, newInput);
        else{
            inputsReady = true;
            //initTimer();
        }
    }

}

and the python script:
global arduino
PORT = '/dev/ttyACM0'
FILENAME = "fginputs.txt"
#Read file with inputs
with open(FILENAME) as f:
        content = f.readlines()
#init serial port
arduino = serial.Serial(PORT, 9600, timeout=1);
time.sleep(2);

#write
for input in content:
    arduino.flush()
    arduino.write(input)
    time.sleep(.1);
    resp = arduino.read();
    print "i got " + resp

#Finish transmission with -1
arduino.flush()
arduino.write("-1")
#done
arduino.close();

The fist time I execute the script I get this:
i got 4
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 5
i got 4

Which is great. But if I run it a second time I get this:
i got 0
i got 4
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0
i got 0

Which is terribly wrong because the file hasn't changed. I don't know what is going on here. If I unplug and plug back in the USB cable, transmission works flawlessly again.


texts: Serial.println Sensor Value and text in one line

texts:
How do I put the sensor value and text on the one line in the serial monitor.

I just want Pot Value 30 to show in the serial console. What am I doing wrong?

Serial.println("POT value ")(sensorValue);


texts: Binary to decimal using bitwise operators

texts:
I am trying to convert some binary data to decimal numbers. I succeeded to convert binary to hex, but now I want to do the same with binary to decimal. I want to use bitwise operators and NO array.

See my code from binairy to hex. The incoming data is 8 bits. This code first calculates the most significant number, and then, the least significant number. This works good, but I cannot figure it out for bin to dec

The function console_print_char is sort of the printf function of my program.

    void console_print_hex_char(unsigned char data){
    unsigned char temp;

    if(data){
        temp = (data >> 4);
        if(temp){
            if(temp> 9) console_print_char(temp + ('A'- 10));
            else console_print_char(temp + '0');
        }
        temp = data & 0x0F;
        if(temp> 9) console_print_char(temp + ('A'- 10));
        else console_print_char(temp + '0');
    }
    else{
        console_print_char('0');
    }
}


texts:
I am pairing an Arduino UNO with a Yost Labs 3-Space Sensor Nano, the user manual for said sensor can be found here: 1.
This is my code, pretty straight forward (although this is my first time working with SPI). I am 100% sure the wiring is correct.
I believe that as per the user manual, this should successfully return 3 floats in 4 bytes each, corresponding to the filtered euler angles of pitch, yaw, and roll. However, all I am reading is bytes full of 0xFF which I believe corresponds to null / no command.
Are there any visible errors in my code?
#include <SPI.h>

SPISettings settings(6000000, MSBFIRST, SPI_MODE0 ); //variable to hold SPI settings
//Set Slave Select, MOSI, MISO, CLK
const int CSN = 10;
const int SI = 11;
const int SO = 12;
const int CLK = 13;

// Needed to convert the bytes from SPI to float
union u_types {
   byte b[4];
   float fval;
} data[3];  // Create 3 unions, one for each euler angle

void setup() {
 //Set Pin Modes
 pinMode(CSN, OUTPUT);
 pinMode(SI, OUTPUT);
 pinMode(SO, INPUT);
 pinMode(CLK, OUTPUT);
 //Set Slave Select High to Start i.e disable chip
 digitalWrite(CSN, HIGH);
 //Initialize SPI
 SPI.begin();
 //pour a bowl of serial
 Serial.begin(9600);
}

//function to transfer commands through SPI
byte transferByte(byte byteToWrite) {

 byte Result = 0x00;
 digitalWrite(CSN,LOW);
 delay(1);
 Result = SPI.transfer(byteToWrite);
 delay(1);
 digitalWrite(CSN,HIGH);
 return Result;
}

//function to swap endian
void endianSwap(byte temp[4]) {
 byte myTemp = temp[0];
 temp[0] = temp[3];
 temp[3] = myTemp;
 myTemp = temp[1];
 temp[1] = temp[2];
 temp[2] = myTemp;
}

void loop() {
 SPI.beginTransaction(settings);

 // Clear the internal data buffer on the IMU
 byte result = transferByte(0x01);
     Serial.print("Cleared internal buffer. Result: "),Serial.println(result);

 // Send start of packet:
 result = transferByte(0xF6);
      Serial.print("Send start of packet. Result: "),Serial.println(result);

 // Send command (tared euler angles)
 result = transferByte(0x01);
      Serial.print("Send commmand 0x01. Result: "),Serial.println(result);

 // Get status of device:
 result = transferByte(0xFF);
      Serial.print("Status of device. Result: "),Serial.println(result);

 while (result != 0x01) {  // Repeat until device is Ready
   delay(1);
   result = transferByte(0xFF);
   Serial.print("Status of device. Result: "),Serial.println(result);
 }

 // Get the 12 bytes of return data from the device:
 for (int ii=0; ii<3; ii++) {
   for (int jj=0; jj<4; jj++) {
     data[ii].b[jj] =  transferByte(0xFF);
     delay(1);
   }
 }

 SPI.endTransaction();

 for( int mm=0; mm<3; mm++) {
   endianSwap(data[mm].b);
 }

 Serial.print("fval 1:"), Serial.println(data[0].fval);
 Serial.print("fval 2:"), Serial.println(data[1].fval);
 Serial.print("fval 3:"), Serial.println(data[2].fval);

 delay(3000);
}


texts:
I'm trying to send data from Arduino Mega to UNO.
The master code sends characters 'x' and 'a' every half second to the slave Arduino UNO.
Slave receives the characters and switches the state of the onboard LED.
Here I'm trying to print some text in the beginning of the loop and the characters received.
Instead of the letters it is printing numbers as given below.
Why this line Serial.println('Soft serial avaialble') prints numbers?
How to print real text received from the master?
> 27749
> 97
> 27749
> 120
> 27749

Master code:
// Include the Software Serial library
#include <SoftwareSerial.h>
// Define a Software Serial object and the used pins
SoftwareSerial softSerial(8, 9);  // RX, TX
void setup()  {
    Serial.begin(9600);
    softSerial.begin(9600);
}
void loop()  {
    // Sends characters 'x' and 'a' every half second.
    if (Serial.available())  {
        softSerial.write('x');
        delay(500);
        digitalWrite(LED, LOW);
        delay(500);
    }
}

Slave code:
// Include the Software Serial library
#include <SoftwareSerial.h>
// Define a Software Serial object and the used pins
SoftwareSerial softSerial(8, 9);
// LED Pin
int LED = 13;

void setup()  {
    softSerial.begin(9600);
    Serial.begin(9600);
    pinMode(LED, OUTPUT);

}
void loop()  {
    Serial.println('Soft serial avaialble');
    if (softSerial.available())  {
        int com = softSerial.read();
        if (com == 'x')  {
            Serial.println(com);
            digitalWrite(LED, LOW);
        } else if (com == 'a'){
            Serial.println(com);
            digitalWrite(LED, HIGH);
        }
    }
}


texts: I use Bluetooth to control LED,but LED can not turn off

texts:
I use android to send the data to Arduino. when i send 0x02, LED turn on, and the breathing LED code are work. But when i send 0x03, it can not turn off the LED. i use UNO R3 the bluetooth is HC06

char data;
void setup()
{
  Serial.begin(9600);
  pinMode(9, OUTPUT);
}

void loop()
{

  if (Serial.available())
  {
    data = Serial.read();

  switch(data){

    case 0x02:

      for (int a = 0 ; a < 255; a=a-1){
        analogWrite(9, a);
        delay(10);
      }
      for (int a = 255; a>0; a=a-1){
        analogWrite(9, a);
        delay(10);
      }

      break;
    case 0x03 :
      digitalWrite(9, LOW);
      break;
    default:
      break;
    }
  }
}


texts:
Probably something easy but I’ve not resolved it.

I’m extracting data from a JSON string and all the values are correct accept for two.

They are referring to two date time values and are in milliseconds.

One is the date refreshed and the other is date updated.

Problem is they are both very large and I’m having difficulty assigning them in the IDE.

One is 1588447162117 which is showing as 020-05-02 20:19:53.948  on the dashboard using the JSON.

Here is the code I have thus far to get the data from JSON:

#include <ArduinoJson.h>

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

  const char* input = "{TotalCases:3308678,TotalCasesToday:4458,TotalDeaths:234123,TotalDeathsToday:293,TotalRecovered:1042991,TotalTerritories:124,CurrentUpdatedMS:1588312648603,CurrentChangedMS:1588312648603}";

  StaticJsonDocument<512> doc;

  DeserializationError err = deserializeJson(doc, input);

  if (err) {
    Serial.print("Error: ");
    Serial.println(err.c_str());
    return;
  }

  unsigned long TotalCases = doc["TotalCases"];
  unsigned long TotalCasesToday = doc["TotalCasesToday"];
  unsigned long TotalDeaths = doc["TotalDeaths"];
  unsigned long TotalDeathsToday = doc["TotalDeathsToday"];
  unsigned long TotalRecovered = doc["TotalRecovered"];
  unsigned long TotalTerritories = doc["TotalTerritories"];
  unsigned long CurrentUpdatedMS = doc["CurrentUpdatedMS"];
  unsigned long CurrentChangedMS = doc["CurrentChangedMS"];

  Serial.print("Total Cases: ");
  Serial.println(TotalCases);
  Serial.print("Total Cases Today: ");
  Serial.println(TotalCasesToday);
  Serial.print("Total Deaths: ");
  Serial.println(TotalDeaths);
  Serial.print("Total Deaths Today: ");
  Serial.println(TotalDeathsToday);
  Serial.print("Total Recovered: ");
  Serial.println(TotalRecovered);
  Serial.print("Total Territories: ");
  Serial.println(TotalTerritories);
  Serial.print("Update time in ms:");
  Serial.println(CurrentUpdatedMS);
  Serial.print("Change time in ms:");
  Serial.print(CurrentChangedMS);
}

void loop()
{

}

**Serial monitor output**

Total Cases: 3308678
Total Cases Today: 4458
Total Deaths: 234123
Total Deaths Today: 293
Total Recovered: 1042991
Total Territories: 124
Update time in ms:0
Change time in ms:0

Should be good to manipulate it once I can work with it in a variable.

Thanks for any input,

Shane


texts:
I have a small motor, it powers fine from the 3V3 and GND output of the arduino nano ble 33. However I need to be able to switch it on and off. My first attempt was to use an output pin, but that doesn't supply enough power. I'm trying to use a 2N3904 transistor (my first time attempting to use one, so sorry if I've done something stupid). I've tried wiring it as follows, but no luck:

Is this possible, or do I need something more substantial like a reed switch?


texts: How to send AT Commands by code using Arduino uno, ESP 8266 01

texts:
What I'm trying to achieve ==> Connect to my WIFI hotspot by AT commands via code then connect to my local node server by using REST API.
Currently, I am able to send AT commands and receive responses via serial monitor when I upload an empty sketch. But when I try it via code. It's falling.
One more thing I flash my ESP8266 01 by esp8266_flasher.exe. Baud rate is 9600(AT commands are working).
This is how I wired the Arduino Uno and ESP8266 01
Vcc -> 3,3V of Arduino
Gnd -> Gnd of Arduino
Rx  -> Rx of Arduino
Tx  -> Tx of Arduino
CH_PD -> 3.3V of Arduino

CODE run on Arduino Uno to connect to WIFI
#define SSID "MY-WIFI" //"SSID-WiFiname"
#define PASS "MY_WIFI_PASSWORD"  //"password"

void setup() {
  Serial.begin(9600);               //Initialise Serial communication at 9600 bps
  Serial.println("AT");              //When baud rate matches, Print AT on Serial Monitor
  delay(5000);

  //Condition to check Whether Serial finds Ok response from ESP8266 or not
  //If It finds Ok response the call the connectWifi() Function
  if (Serial.find("OK"))
  {
    connectWiFi();

  }else {
    Serial.println("NOT Find OK");
  }
}

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

boolean connectWiFi()

{
  //Enable the module to act as both Station and an access point
  Serial.println("AT+CWMODE=1");
  delay(2000);
  //Join the WIFI access point
  String cmd = "AT+CWJAP=";
  cmd += SSID;
  cmd += "", "";
  cmd += PASS;
  cmd += "";

  //Print the Wifi SSID and Password on Serial monitor
  Serial.println(cmd);
  delay(5000);

  if (Serial.find("OK"))
  {
    Serial.println("Connect to WIFI");
    return true;
  }
  else
  {
    return false;
  }
}

My code is falling in Serial.find("OK") this line.
OUTPUT when I run code on Arduino Uno with connecting ESP8266 01

I couldn't figure out What I did wrong. If anyone can help me to achieve my goal with any good resources or tutorials, please let me know.
I went through the previously asked questions, But they didn't help me.


texts: How to use Due PB0-PB7 pins as an external interrupt

texts:
In my board I need to use PB0-PB7 ports as an external interrupt sources.

Is it possible?

I spent a lot of time to understand that. Seems the easiest way is to update variant.cpp file by adding these pins.

Unfortunately this is not the solution I'm looking for (actually this can be a solution if I'm able to add pins from the sketch, but it is not possible to update cons dynamic array after declaration ).

Another way is to create my own interrupt handler. But I didn't find how should I do that.


texts:
So today I started to learn Arduino uno. I have an LM35 temperature sensor and I got what I needed from it. Now it's just keep calculating till I plug it off.

I know there is a reset button. When I press it or hold it, it's closing and opening again to do the coding again. I want it to completely stop. Like when I first plug led was flashing to show arduino is connected.

And I know I can just upload another code. But I don't want that.

If it's possible please let me know.


texts: SMS Receiving problem - Arduino Uno and SIM900A GSM Module

texts:
My intention is to control an LED according to the content of the SMS received. For example, if the SMS is "ON", turn on the LED and if it is "OFF", turn it off. I referred many sites and got the below code.
The digital pins 9 and 10 are used instead of Rx and Tx to avoid the code uploading problem.

(I have kept the different versions of AT commands commented in the code because I'm not sure which one is correct. With the current one, I'm able to get some kind of output which I've mentioned after the code.)

#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);

char msg;
void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);   // Setting the baud rate of GSM Module
  delay(1000);
  //mySerial.print("AT+CMGF=1r"); // set SMS mode to text
  mySerial.print("AT+CMGF=1\r");  // set SMS mode to text

  delay(100);
  //mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  //mySerial.print("AT+CNMI=2,2,0,0,0r");

  mySerial.print("AT+CNMI=1,2,0,0,0\r"); // AT Command to receive a live SMS
  delay(100);
  Serial.println("Ready");
}

void loop()
{
  if (mySerial.available()>0)
  {
    msg=mySerial.read();
    Serial.print(msg);
  }
}

This is the output I'm getting..

Ready
AT+CMGF=1
AT+CNMI=1,2,0,0,0

OK

+CMTI: "SM",31

+CMTI: "SM",32

+CMTI: "SM",33

+CMTI: "SM",34

The issue is, I'm not able to retrieve the message content. What I'm getting is

"+CMTI: "SM",31"

"+CMTI: "SM",32"

and the number keeps on incrementing. (33, 34 and so on).

I do understand that I have to parse the message to get the exact content, but here I'm not getting the content at all. What exactly should I do to get the SMS content? Could anybody help me to solve this?

One more thing, the GSM module I'm using is a SIM900A type (from elementzonline.com). It's not a shield type, so I've made connections using wires; the Rx, Tx connections and the ground one.

(Sorry for the bad explanation, I'm a complete noob in Arduino, a hobbyist.)

Thanks in advance.


texts:
I wish to connect 2 simple 5V DC Brushless Fan (80x80x15mm, https://www.sparkfun.com/products/9649) to Ardumoto (https://www.sparkfun.com/products/9815).

Therefore, how to I turn on/off the fan as I do not know how to address it? Do I need to connect a power supply to the Ardumoto, to the Arduino board or 2 separate power supplies to each one of them?

Thanks.


texts:
I want to buy a camera module for Arduino. I came across this OV7670 CMOS Camera Module Lens CMOS 640X480 SCCB W/ I2C Interface Arduino and CMOS With AL422 3M-Bits OV7670 FIFO Camera .

I want to know what difference does FIFO makes in a camera? If I dont use a FIFO will the quality of video be compromised?


texts: Detecting ball moving between IR pair and handling ambient light changes

texts:
I plan to use the SEN-00241 IR Emitter and Detector pair to detect a ping pong ball moving fast between them.

I understand I could watch for voltage changes to detect this passing object, however how do people generally deal with ambient light changes? From my research it seems that the voltage will change with ambient light, and although I can take steps to create funnel vision between the 2 I'm sure it may still be an issue.

Would you take constant readings and find averages over 10 consecutive readings to allow for changes in ambient light and set a new baseline reading? Then if the voltage changes dramatically and only for a few reads then I know that was the ball and not to change the baseline reading.


texts: Run website / Javascript game from a Arduino UNO device?

texts:
I apologise if this is a dumb question, but I'm trying to find information on whether or not this is possible. I'd like to build a arcade machine to play my custom Javascript 2D game. The game currently runs in the browser (of course), but is it possible to execute the code in the Arduino. I'd like to make an arcade machine that runs from the Arduino and connect the game controls to a joystick. Can anyone tell me is this is possible, or any suggestions about how I can achieve this without rewriting the application.

I found the below link that has some information but this is for a PI
https://www.raspberrypi.org/forums/viewtopic.php?t=194808


texts:
I have an issue with debouncing.
I am using a MCP23017 as an I/O-extender with an Arduino. This uses I2C to communicate with each other.

A variable amount of switches is connected to the MCP23017 (0-16 switches). On change of the inputs, an interrupt is generated and the Arduino captures this on rising edge. So whenever a button is pushed or released, an interrupt is generated.

Now I'm confused as how I should debug them. One option would be to set a delay after an interrupt (of let's say 50 ms), before turning the interrupts back on. This could have an issue however, since multiple inputs are connected to the same interrupt line.

Another option is to have a timestamp or something for the last time each switch was changed, and check if the time difference is big enough, otherwise ignore the next pulse. The problem with this is that it uses quit some resources as I have limited memory and there can be up to 8 extenders (so 8 * 16 = 128 inputs).

What is the most efficient way to handle these interrupts with debouncing?


texts:
I am building a robot for a school project. I use an Arduino Uno, 2 dc motor's and an Ultra Sonic range measurement module. I want the robot to be autonomous, he has to be able to move around on his own using the Ultra Sonic sensor. Important to mention is that I don't use a MotorShield to control my dc motors. This is my latest version of coding:

#include <Servo.h> //include Servo library
#include <AFMotor.h> //include DC motor Library
#define trigPin 12// define the pins of your sensor
#define echoPin 13
AF_DCMotor motor2(7); // set up motors.
AF_DCMotor motor1(6);

void setup() {
  Serial.begin(9600); // begin serial communitication
  Serial.println("Motor test!");
   pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves)
  pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves)
  motor1.setSpeed(105); //set the speed of the motors, between 0-255
    motor2.setSpeed (105);
}

void loop() {

   long duration, distance; // start the scan
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2); // delays are required for a succesful sensor operation.
  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10); //this delay is required as well!
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;// convert the distance to centimeters.
  if (distance < 25)/*if there's an obstacle 25 centimers, ahead, do the following: */ {
   Serial.println ("Close Obstacle detected!" );
Serial.println ("Obstacle Details:");
Serial.print ("Distance From Robot is " );
Serial.print ( distance);
Serial.print ( " CM!");// print out the distance in centimeters.

Serial.println (" The obstacle is declared a threat due to close distance. ");
Serial.println (" Turning !");
    motor1.run(FORWARD);  // Turn as long as there's an obstacle ahead.
      motor2.run (BACKWARD);

}
  else {
   Serial.println ("No obstacle detected. going forward");
   delay (15);
   motor1.run(FORWARD); //if there's no obstacle ahead, Go Forward!
    motor2.run(FORWARD);
  }

}

Now I added an ARDUINO MOTOR SHIELD REV3 to control my dc motors. Now the wheels are actually spinning, but after a few turns they stop. I think it is software related, but I am not 100% sure. Also I think I am connecting my motors correct to my motorshield, but don't adress them properly in my code.
And I don't have any clue how to solve this problem.
Can anybody help me with this?


texts: Since it is not right to use millis() in an ISR to calculate duration of the input, Is it correct to use pulseIn()?


texts: SD test is taking long answer when it fails

texts:
I am working on an Arduino application that logs sensors values into SD files. It is essential that the SD is inserted and working when a test is started, thus I need to check the presence of the SD regularly (every 2 seconds or so) to prevent launching a test without SD inserted by the user.

When I run the following code, it runs very fast when the SD test succeeds (<10ms), but it takes more than 2000ms when the test fails. Is there another test I could run that does not takes 2 seconds to indicate that the SD is not inserted (or not working)? All my buttons are frozen and they do not trigger any action while checking if no SD is inserted.

Here is my code (both loops have the same issue):

#define csSD   53
#include <SD.h>

Sd2Card card;

void setup() {
  Serial.begin(57600);
  bool SDOK = SD.begin(csSD);
  if(SDOK) {
    Serial.println("SD.Begin Setup OK");
  } else {
    Serial.println("SD.Begin Setup Fail");
  }
}

unsigned long t;
//void loop() {
//  t=millis();
//  if(SD.begin(csSD)){ // SD.Begin test runs fast when there is a SD, even though it return true when you try to begin SD a second time
//    Serial.print("SD.Begin loop OK : ");
//  }else {
//    Serial.print("SD.Begin loop Fail : ");
//  }
//  Serial.println(String(millis()-t)+"ms");
//  delay(500);
//}

void loop() {
  t=millis();
  if(card.init(SPI_HALF_SPEED, csSD)) {
    // card.init test returns true as it should (when SD is present and working), but runs fast only when SD is working
    Serial.print("card.init loop OK : ");
  } else {
    Serial.print("SD.Begin loop Fail : ");
  }
  Serial.println(String(millis()-t)+"ms");
  delay(500);
}


texts: NodeMCU (ESP8266) board controlled over shared hosting database

texts:
I have a NodeMCU (ESP8266) board that I want to control over the internet. I am trying to find a solution where I don't have to set up any configurations on my router like port forwarding. I came up with the following solution:

I have a website where the user changes the device status (with status I mean for example GPIO5 pin value HIGH or LOW) which is then saved to a database on a shared hosting server. The NodeMCU sends periodically (for example every 5 seconds) a HTTP GET request to the database. According to the value that is received from the database the NodeMCU board changes the pin value to HIGH or LOW. If NodeMCU changes it's status (for example a pin value from HIGH to LOW) the new device status is sent to the database with a HTTP POST request. The device also sends a HTTP POST request periodically (for example every 60 seconds) so the user can monitor the device status on the website.

There are a few problems with this configuration:

There is no real-time connection between NodeMCU and the user (there
is always a delay in the device response)
The device sends thousand of queries every day that are a load to
the shared hosting server. For example if the GET request is sent
every 5 seconds, that gives 17280 queries per day for one device.

So my question is how practical is this configuration on shared hosting or any kind of hosting, what are the alternatives or improvements to this configuration and how to establish a connection with the NodeMCU so that the device sends a GET request to the database only when the device status is changed in the database by the user.


texts: Multi-file arduino esp8266 sketch sharing a reference to server

texts:
Transferred from stackoverflow on the advice of @Gee_Bee:

  I can get Writing a Library for Arduino to work as well as
  Breaking a sketch into multiple files and Classes within Classes
  - Initialiser Lists. I can even get extern references to variables to work but referencing the an instance of ESP8266WebServer in
  different files is still beyond me.

As my sketches get bigger, the code looks awful as one file and the number of global variables is too high.

For the webconfig part of my sketch the device attempts to get online and if it fails it scans for available Wi-Fi networks, goes into Access Point Mode, starts a server, sends the list of SSID's and listens for a response of an SSID/password pair. The server is only for the configuration.

Ideally I'd like the cleaned up main.ino file to look like

    #include "config.h"
    void setup(){
        Serial.begin(115200);
        Serial.println();
        Serial.println("--------------------------");
      Serial.println("ESP8266 multifile");
      Serial.println("--------------------------");
      getOnline();
    }
    void loop(){
        if(IN_CONFIG_MODE){
           server.handleClient();
        }
    }

with a config.h something like..

    #ifndef config_h
    #define config_h
        #include <ESP8266WiFi.h>
        #include <ESP8266WebServer.h>
        ESP8266WebServer server;
        void getOnline();
    #endif

and then a config.cpp where it does all stuff described above yet gives the main.ino program access to the server instance so it can listen in the main loop.

#include "config.h"
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

char *espssid = "espAPsb";
char *ssid = "street_no_vale2";
char *pwd = "jjjjjjjjx";
char ssids[300];

extern server(80);

void handleRoot(){
    server.send(200, "text/html", "
root of espAPsb AP server
");
    //send json of available ssids
}

void scan(){
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0)
    Serial.println("no networks found");
  else
  {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i)
    {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
      delay(10);
    }
  }
  Serial.println("");
}

void setupAP(){
    WiFi.softAP(espssid);
    server.on("/", handleRoot);
    server.begin();
  Serial.println();
  Serial.print("connected as AP ");
  Serial.println(espssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.softAPIP());
}

void getOnline(){
    WiFi.begin(ssid, pwd);
  int tries =0;
  int success=1;
  while (WiFi.status() != WL_CONNECTED ) {
    delay(500);
    Serial.print(".");
    tries++;
    if (tries==15){
      success=0;
      Serial.println("WiFi not connected");
      scan();
      setupAP();
      break;
    }
  }
  if (success){
    Serial.println("");
    Serial.println("WiFi connected");
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
  }
}


texts: Why do I need to use latin-1 instead of utf-8 when using python with arduino?

texts:
When reading and writing with a python serial port connection to arduino, if I don't use latin-1 ('ISO-8859-1'), the results are not as expected. Like if I have
int outP = 5;
//...
int outV = Serial.read();
analogWrite(outP, outV);

While with python I have
serial_port.write(chr(255).encode())

I read 3.78 V from the pin, whereas if I use
serial_port.write(chr(255).encode(encoding = 'latin-1'))

I get 5.04 V. I have read latin-1 and utf-8 don't always match, but is there something about arduino that requires using latin-1? Of course, these return different values when testing each encoding, using 255 gives b'\xc3\xbf' (from 'Ã¿') with utf-8 or b'\xff' from ('ÿ') with latin-1, but why does arduino work with latin-1?
FYI other options that work are
v = 255

serial_port.write(v.to_bytes(1, byteorder = 'big'))

serial_port.write(bytes[v])


texts: Help- Optical Sensor interfacing with Arduino

texts: I am a newbie and I wanted to know if it is safe to connect this NPN output sensor directly to one of the GPIO pins of the Sparkfun redboard. Do I need some extra circuitry or components? Thanks


texts: Thermistor returns correct value on Arduino Nano, completely fails on Arduino Uno Wifi Rev 2?

texts:
I am completely baffled. When I wire the thermistor into my Nano, everything reads completely fine. Then when I switch to the Uno Wifi Rev 2, I get negative numbers -40 to -80 when I was reading 24 on the Nano.
Wiring Diagram is:
           Thermistor
           |       |
Gnd---Resistor     Vcc
           |
       A6/A0 (6 for nano, 0 for Uno)

Code is:
#include <thermistor.h>
#define pin A6 //I change this to A0 on the WIfi. This is the only change
float temp;
uint32_t timeout = millis();
THERMISTOR thermistor(pin, //Analog pin
                  9800,    //Nominal res at 25 ºC
                  3559,    //Thermistor's B value
                  10000);  //Value of the resistor
void setup() {
  Serial.begin(9600);
}

void loop() {
  delay(1000);
  temp = thermistor.read();
  Serial.println(temp);
}


texts: How to define function/macro so it is accesible throughout various cpp files

texts:
I recently came across this nice SerialPrint() implementation:

void StreamPrint_progmem(Print &out,PGM_P format,...)
{
  // program memory version of printf - copy of format string and result share a buffer
  // so as to avoid too much memory use
  char formatString[128], *ptr;
  strncpy_P( formatString, format, sizeof(formatString) ); // copy in from program mem
  // null terminate - leave last char since we might need it in worst case for result's \0
  formatString[ sizeof(formatString)-2 ]='\0';
  ptr=&formatString[ strlen(formatString)+1 ]; // our result buffer...
  va_list args;
  va_start (args,format);
  vsnprintf(ptr, sizeof(formatString)-1-strlen(formatString), formatString, args );
  va_end (args);
  formatString[ sizeof(formatString)-1 ]='\0';
  out.print(ptr);
}

#define Serialprint(format, ...) StreamPrint_progmem(Serial,PSTR(format),##__VA_ARGS__)
#define Streamprint(stream,format, ...) StreamPrint_progmem(stream,PSTR(format),##__VA_ARGS__)

I want to use it in my more complex projects to save precious RAM space.

This works really well when I have just one *.ino file where I'm using the SerialPrint() function.
When I try to use it in my more complext projects, which consist of a central *.ino files and several .cpp/.h files (mostly one cpp/h pair per class).
The problem is if I put the code below into the *.ino file, it will not be known inside any of the *.cpp files. The compiler is not complanining, but I'm never seeing the serial output of my code.

Any ideas how to fix it?
I've tried putting this code in a central global.cpp/h file which I include everywhere, but it does not seem to work (no output on serial).

Thanks in advance!-


texts: Serial communication arduino mega and D1 Wemos Mini

texts:
Can anyone help me connecting arduino mega to D1 Wemos Mini serially? Please let me know most efficient and easy steps to setup a communication.

Using that following tutorial:

https://engineeringprojectshub.com/serial-communication-between-nodemcu-and-arduino/amp/

Following is the circuit diagram:
https://i.stack.imgur.com/oOKwL.png


texts: Floating power supply for Arduino - Is it still connected to the USB ground?

texts:
I am trying to power my Arduino Mega 2560 from a benchtop power supply. I plan to essentially feed in a 9V supply directly on the Vin pin and connect the GND pin to the floating ground pin on the power supply. I noticed on the schematic that the UGND is connected to GND through this jumper. On the Arduino that I have these two pins are tied together. Does this mean that even with the external power supply the Arduino will be connected to the UGND, and in effect the protective earth?

What is the best way to float the Arduino? Would it be ok to remove the jumper connection between UGND and GND? Or should I try something like a linear USB isolator like this?


texts:
I have an ESP-WROOM-32 and I'm using Arduino IDE to push code on it. My ESP is powered via 2 AA batteries and got one power supply problem.

It works well on new battery but after a bit, I will always get this error repeatedly:

  ets Jun  8 2016 00:22:57

  rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0,
  SPIWP:0xee
  clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  mode:DIO, clock div:2 load:0x3fff0018,len:4 load:0x3fff001c,len:812
  load:0x40078000,len:0 load:0x40078000,len:11584 entry 0x40078a60

  Brownout detector was triggered

So, I know that it's possible to disable that feature in ESP32. My question is how to do it?

What I have done that didn't work:

Add this code in my Arduino IDE:

#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
setup(){
    WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
}

Change Arduino\hardware\espressif\esp32\tools\sdk\sdkconfig with:

CONFIG_BROWNOUT_DET=                //previous was "=y"
CONFIG_BROWNOUT_DET_LVL_SEL_0=      //previous was "=y"
CONFIG_BROWNOUT_DET_LVL_SEL_1=
CONFIG_BROWNOUT_DET_LVL_SEL_2=
CONFIG_BROWNOUT_DET_LVL_SEL_3=
CONFIG_BROWNOUT_DET_LVL_SEL_4=
CONFIG_BROWNOUT_DET_LVL_SEL_5=
CONFIG_BROWNOUT_DET_LVL_SEL_6=
CONFIG_BROWNOUT_DET_LVL_SEL_7=
CONFIG_BROWNOUT_DET_LVL=           //previous was "=0"


texts: Alternatives to read mp3 without using an sdcard as source for the files?

texts:
I am making a project that plays several sounds using a DFPlayer Mini mp3 player and a micro sd card. The size of the sounds I normally play is less than 20 MB, so a lot of space in the sd card is unused. I was wondering if there is an alternative to use an SD card to store the mp3 files, and if there is, what would be the best approach to switch to use this alternative.

Cheers!


texts:
I am using Eclipse to program a ATMega2560 and would like to stay away from the Arduino library, While looking through AVR Examples I have seen the syntax

#include <avr/io.h>

PORTD.0 = 1

or

PORTD.DIR = 1;

instead of

PORTD = 0b11111111;

To define and control the Inputs/Outputs when I try to use this syntax I get compiler errors:

error: request for member 'DIR' in '*34u', which is of non-class type 'volatile uint8_t {aka volatile unsigned char}'

I am sure that I am simply missing a include file or something but I can't figure out what I am doing wrong.


texts: WS2811 strip not working on NodeMCU, works fine on Nano

texts:
Sorry if this is something simple, but im scratching my head over this for a while and there are a few things that have me super confused.

I have two WS2811 strips lighting up my outdoor stairs
Both are powered from a central point, using Cat5 Cabling to get power and data from the controller to the start of each strip

Iv been running it from a Nano perfectly fine for a while, but wanted to add networking so upgraded to a NodeMCU

I first started on just one strip to confirm it worked as expected, and after setting about 50 of the 80 leds it started to glitch, so I added a 3.3 to 5v converter and the issues went away.

I then went to work on the second strip, and was getting nothing from it,
no commands sent to the strip were working, the first strip kept working fine however.

I swapped around the pin outputs and converters in case it was a faulty part or bad pin, but no matter the combination, it worked 100% when using the first strip, and never worked on the second.

So i put my Nano back in, running the same color swap test code I had, and both strips worked fine, put the Node back in and only the one strip worked.

I then got a small test strip and connected it directly to the output of the converters and when it was on the one for the first strip, it worked fine (With both the test and first strip displaying the same test)
But when I put it on the output for the second strip, the test strip would turn off as if it was getting a "Set all to 0" command.

I disconnected the cat5 that connected the converter to the second strip, and the test strip started working.
So I thought there must be a short or something on the cat5
So I disconnected the LED strip from the other end and did a continuity test, and none of the leads were shorting (Pos, Neg and Data)

So I put the cable back onto the converter, with nothing on the other end, and the test strip stopped working again,
I dont know if the length of the cat5 is causing a capacitance issue or something, even though its only connected on one end (Converter end)
And it works fine with the nano, only when its the Node and only with the second strip do I have problems

Hopefully my description makes sense, and someone has some idea of whats going on

Link to diagram of my setup https://imgur.com/a/pTefyR5
And happy to try make a short clip if a visual guide would help explain my problem

Thanks in advance


texts: Where does the Arduino core include the name of the sketch?

texts:
I'm trying to look through the Arduino core to find where "mySketch.ino" is included or implemented. In 'Arduino.h', the prototypes void setup(void) and void loop(void) are defined, in 'main.cpp', setup(void) and loop(void) are called, but I'm not sure where 'main.cpp' or any other related files makes a reference to the sketch.

Where does this occur?


texts:
I have a ESP8266-01 and am trying to get it to work. I am using the example WiFiScan code shown below.

#include "ESP8266WiFi.h"

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

  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  Serial.println("Setup done");
}

void loop() {
  Serial.println("scan start");

  // WiFi.scanNetworks will return the number of networks found
  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0) {
    Serial.println("no networks found");
  } else {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i) {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
      delay(10);
    }
  }
  Serial.println("");

  // Wait a bit before scanning again
  delay(5000);
}

I have a voltage regulator producing 3.3 V connected to CH_PD and the Arduino powers the ESP's VCC via the 3.3 V pin. TX is connected to TX and RX is connected to RX. GPIO0 is connected to ground. I can upload, but it cannot find any networks. It always states no networks found. Now I'm not even sure how to proceed... Any help would be appreciated.


texts: Simple relay switching program crashes UNO

texts:
A very simple

digitalwrite(pin, HIGH)
delay(1200)
digitalwrite(pin, LOW)
delay(1200)

crashes the uno after about half an hour. Of course it works again after pressing the reset button.

It's switching this relay

Which is connected to a 230v 80W DC motor. The relay cuts the '+'

Because I've read that 230v stuff can be too much for such a litte relay,
I've disconnected the motor and not the relay switches another 24v OMRON P2RF-05-PU (10A250VAC) relay, which has his own 24V Mean Well power supply. And connected the motor to that one.

I thought this solved my problem, but now the Arduino crashes after about 3 hours.
Any thoughts on what else I could try?


texts: Wemos D1 mini won't connect to WiFi: status code 6

texts:
So I have a Wemos D1 mini which I want to connect to my WiFI in order to let is push sensor data to my server. But I cannot connect it with my WiFi as I get a code 6.
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

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

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

The Serial.print(WiFi.status()); prints 6 which is WL_CONNECT_FAILED if I'm right.
I checked the router and it uses WPA/WPA2, the ssid and password are correct. The router is using 2.4 GHz with WiFi 802.11b and 802.11g.
I used the board to scan, with the example code provided by the esp8266 board manager library thing, and it found my SSID with the ones of my neighbors.
Can somebody tell me what is going wrong?
I already checked solutions like: This one , github answers, etc.
Edit: It can connect to a mobile phone hotspot. It gives code 6 1 time and then it connects. Any one an idea how I connect to the WiFi the router is providing ?


texts: Connecting a FireBeetle ESP32 to Arduino

texts:
I have a very basic question, because I struggle to upload files to my FireBeetle ESP32 Board.

When I try to upload to the board I get an

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

On other boards you have to press & hold the flash button, but this specific board just has a reset button.
What can I do?


texts:
I have a SIM 800L module which I am using to send /receive SMS calls.

I just wanted to know whether there is any library suitable for the SIM800 for arduino. I don't need GPRS functionality . I see mostly the arduino shield library but not sure whether it works with the SIM800 module bought from aliexpress.

Can someone help me in get me a library which can be used for the SIM800 .I have tried a lot but not getting a simple library for the same.

Actual Issue :

I am able to make it work with the AT commands using the Serial3 in the arduino MEGA. But when i started integrating with the existing project of ESP8266 and DS3231 somehow the Serial3 read() is not working properly. I tested with Serial3.readString()/ Serial3.read() and all. The CNMI for the SIM800 is 2,3,0,0 which is to direct the incoming message to the Terminal.
If my project is having a simple loop with only Serial3.read, then all messages contents are read properly. If I include the other Serial2 readings which is for the ESP8266, then I am not able to read the full messages from Serial3.I have tried with timer to read serial from the Serial3 for 3-5 secs but now way it is working.


texts: Why does my sketch report too many button presses?

texts:
I've been using a button to interact with a sketch (on my Uno), and it's mostly working fine. However, sometimes it seems to be detecting multiple presses when it's only pressed once.

It's a small circuit-mounted momentary button, which is normally open. It's connected from +5V directly to an input pin. I've also added a 10K pull-down resistor on the pin to make sure the input isn't left floating.

Here's a test sketch I've been using, which reports the number of presses to the serial monitor:

int oldState = LOW;
int numPresses = 0;

void setup()
{
    pinMode(5, INPUT);
    Serial.begin(9600);
}

void loop()
{
    const int newState = digitalRead(5);

    if (newState != oldState) {
        if (newState == HIGH) Serial.println(++numPresses);
        oldState = newState;
    }
}

Sometimes when I press the button once, the serial monitor shows two presses in a row. It sometimes even reports a press when I release the button.

Is it possible to fix this? Or do I just have a faulty button or pin or something?


texts: Using an Arduino Nano, how many LEDs can I safely power?

texts:
I am working on building a wordclock using one of the several design ideas that you can find all over the Internet. Something like a mix of this one: http://www.instructables.com/id/Sleek-word-clock/ and this one: http://www.instructables.com/id/Personalised-Word-Clock/ A lot of the guides suggested building your own Arduino to save money, but I found these Arduino Nano clones for $7/apiece: http://www.amazon.com/gp/product/B00SGMEH7G.

I've done a few simple projects before, but nothing with the same kind of power demand. How can I figure out the power requirements? My plan is to use approximately 64 3mm LEDs via shift register, or possibly the equivalent segments of an LED strip.

The Nano clone does not have a barrel connector for external power adaptor. Should I directly solder on the power cables from an external adaptor? Use a screw terminal or similar? Is the USB adaptor a good enough source of power for 64 LEDs? Or do I have to do something else to supply external power to that many LEDs?

Thanks for any advice! I am experienced in programming but not in electrical engineering so many of the concepts are something I don't have a good handle on yet.


texts: How is AVR Assembly in Eclipse or at Linux command line done?

texts:
I'm trying to learn AVR development in C and Assembly for the Arduino Uno (Atmel 328p microprocessor) in Linux.

I've found many good guides on how to install and setup the AVR plugin for Eclipse, and I've no problem building and uploading C code.
However there doesn't seem to be any menu options for creating an assembler project, nor can I seem to find the correct syntax for using the cli avr-as for assembling my programs into a .hex file.


texts: How to program GPS and Compass guided robot?

texts:
I am using the following things...

Ublox Neo 6m GPS module
HMC58883L magnetometer
HC 05 for BT
HC SR04 for obstacle avoidance
Arduino mega

I am using the following libraries (given as links):

1.HMC5883L library
2.TinyGPSPlus library

Pls provide me with suitable codes(with explanation) and wiring


texts: How do i run multiple functions simultaneously on a LCD screen?

texts:
I have little to no experience in programming and i'm very slowly and gradually getting the hang of it. My next project is that i'm making a clock, and wanted to use multiple functions for the hour:minute:seconds instead of just using one for everything. But after reading some i came to the conclusion that the arduino can only run one function at a time. So my question is how can i make the illusion of multiple functions running simultaneously on a LCD screen.

My code:

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int lcd_key     = 0;
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     144
#define btnDOWN   329
#define btnLEFT   504
#define btnSELECT 741
#define btnNONE   5

int read_LCD_buttons()
{
 adc_key_in = analogRead(0);

 if (adc_key_in > 1000) return btnNONE;
 if (adc_key_in < 50)   return btnRIGHT;
 if (adc_key_in < 195)  return btnUP;
 if (adc_key_in < 380)  return btnDOWN;
 if (adc_key_in < 555)  return btnLEFT;
 if (adc_key_in < 790)  return btnSELECT;
 return btnNONE;

}
unsigned long minInterval = 60000UL; // Interval for minutes in milliseconds
unsigned long secInterval = 1000UL;  // Interval for seconds in milliseconds
unsigned long prevMinMillis = 0UL;   // Holds the timestamp of the last time Minute() was called
unsigned long prevSecMillis = 0UL;   // Holds the timestamp of the last time Second() was called

void setup()
{
 lcd.begin(16, 2);
}

void loop()
{
  unsigned long currentMillis = millis();

  if (currentMillis - prevMinMillis > minInterval)
  {
    prevMinMillis = currentMillis;
    Minute();
  }

  if (currentMillis - prevSecMillis > secInterval)
  {
    prevSecMillis = currentMillis;
    Second();
  }

}

void Second(){
  int First_Digit = 0;
  int Second_Digit = 0;

  for(Second_Digit; Second_Digit<10; Second_Digit++){
    if(Second_Digit==10){
      First_Digit = First_Digit + 1;
      }

    lcd.setCursor(0, 0);
    lcd.print(First_Digit);
    lcd.setCursor(1, 0);
    lcd.print(Second_Digit);
    lcd.clear();

    if(First_Digit==5 && Second_Digit==9){
      First_Digit = First_Digit - 5;
      Second_Digit = Second_Digit -10;

      }
    if(Second_Digit==9){
      First_Digit = First_Digit + 1;
      Second_Digit = Second_Digit - 10;
      }

  }
}
void Minute(){
  int First_Digit = 0;
  int Second_Digit = 0;
  for(Second_Digit; Second_Digit<10; Second_Digit++){
    if(Second_Digit==10){
      First_Digit = First_Digit + 1;
      lcd.print(First_Digit);
      }

    lcd.setCursor(3, 0);
    lcd.print(First_Digit);
    lcd.setCursor(4, 0);
    lcd.print(Second_Digit);
    lcd.clear();

    if(First_Digit==5 && Second_Digit==9){
      First_Digit = First_Digit - 5;
      Second_Digit = Second_Digit -10;
      lcd.print(First_Digit);

      }
    if(Second_Digit==9){
      First_Digit = First_Digit + 1;
      lcd.print(First_Digit);
      Second_Digit = Second_Digit - 10;
      }

  }
}


texts: Need a proper diagram to connect my multiple relays (more than 8) with only a few pins on Arduino Uno Board

texts:
Specifically, I want to add multiple relays (approximately 36 to 40) to an Arduino Uno board (using only a few pins). I found a solution using ShiftOut. You can take a look here. But here the example is for testing small LEDs bulbs.

I will control high-voltage electricity like fans, tube lights, washing machine with those relays, so what will be a proper graph or image diagram for that? And if you have any more suggestions for me then you can tell me :) And yes please tell me what I should use for it.

Right now am thinking to use an Arduino, relays, 74HC595 IC only. My diagram for controlling LED is like this:

You can edit it. I just need proper guidance for it and a few good suggestions.


texts: How to compare an incoming byte from cool terminal as modbus hex value and compare it with a predefined value in set in the program?

texts:
My Input from Cool terminal is
    05 03 00 01 00 02 94 4F

I should be able to read this input 05 03 00 01 00 02 94 4F compare with the same(05 03 00 01 00 02 94 4F). If the incoming value(05 03 00 01 00 02 94 4F) and the predefined value(05 03 00 01 00 02 94 4F) are the same it should print the hex value like

  05 03 04 43 65 BA 7D 04 E8

I tried to code it but i could'nt get the value.
Here is my code in Arduino

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

    void loop()
    {
      static char buffer[1024];
      static size_t length = 0;

      if (Serial.available()) {
        char c = Serial.read();

        // Otherwise buffer the incoming byte.
        //else if (length < sizeof buffer - 1) {

        Serial.write(c);  // echo
        buffer[length++] = c;
      }
    }


texts: I have cooked 3 regulators applying 12 V to RAW pin. Am I doing something wrong or did I get a bad batch?

texts:
I'm trying to make a simple keypad lock that has a 12 V magnetic lock.  I supplied 12 V to the RAW pin on the Pro Mini with plans to actuate the relay with the 5 V from VCC pin.  The lock was grounded on the terminal strip that the 12 V came from, and then the positive 12 V was switched through the relay.

Everything was working well until I powered the board through the RAW pin with 12 V.  When I did that all three failed the smoke test.

My question is, am I doing something incorrectly or did I happen to get a bad batch (all three of the boards came in the same shipment, I assume they came from the same lot)?


texts: Is new.cpp programmed improperly? Arduino 1.8.9

texts:
I'm having trouble with my code and I'm not sure if it's a memory allocation issue. So I look at the new, delete to see if it throws errors, and finding the source code I find outrageously simple codes. So simple, I think it can't be right.

#include <stdlib.h>

void *operator new(size_t size) {
  return malloc(size);
}

void *operator new[](size_t size) {
  return malloc(size);
}

void operator delete(void * ptr) {
  free(ptr);
}

void operator delete[](void * ptr) {
  free(ptr);
}

Does this mean if I call customClass *ptr = new customClass[10]; it allocates only 10 bytes instead of sizeof(customClass)*10?


texts:
Recently I assembled my Shapeoko machine, we used Grbl shield with an Uno for the same.

For 1-2 weeks everything worked perfectly then once when I tried to work the machine, the serial communication was not working. I tried to replace the 16 MHz oscillator because I thought the problem might be with the oscillator since the LEDs were not blinking but they were lighting up.


texts: Arduino fingerprint verification from server

texts:
I am thinking to do a hobby project related to fingerprint verification. The flow which I wanted to implement is something like below:

A user can register a fingerprint using an Arduino device
This fingerprint will be saved on a remote server so that user can be verified on some other Arduino devices
When a user tries to verify, the fingerprint will be matched against the fingerprint stored on the server

For this, I am thinking to use the Go language on the server side as an API server, MySQL/SQLite as a database system. Further, in the future, I will build a mobile application to perform some query with the server like running devices, the number of registered users, revoke users etc.

For now, I am planning to buy the following devices:

Arduino UNO
A wifi shield
A fingerprint sensor
An LCD screen

Now the question is, will the devices mentioned above will work for my setup, or I need to buy something else (Are they compatible?)

Also, is there a way to store the fingerprint on a server? I am thinking to store some kind of hash (probably RSA encrypted) of a fingerprint on a server, will it work?

Any relevant example of storing fingerprint on a server?


texts:
I have this NFC module. When i read ONE card at a moment everything works fine, but i need to read more that one cart at a moment.

One card lays on a module - module reads it ok, when I move another card over modure, I get a mix of both card's numbers.

Is there any way to read both card at one moment correctry?

I read card like this. As a bord I use NodeMCU ESP8266 ESP-12E

SoftwareSerial rfid(RFID_RX, RFID_TX);
..
void loop()
{
    rfid.listen();
    delay(500);

    while (rfid.available() > 0) {
        Serial.println("Closest card number: " + rfid.readString());
    }

}


texts: How to connect mini jack output to arduino mini pro and send sound to it?

texts:
I would like to connect arduino mini pro to mini jack output and send sound through it.

What would I need here, how can I connect the mini jack to arduino and how to send data of sounds (any library?) to that connected output?

EDIT

The sound source will be a music file ( streamed via bluetooth). I would like to be able to connect this output to a speaker and play (stream) music via bluetooth.

EDIT

Either mono or stereo will be good for me. My plan is to: stream the music via bluetooth to bluetooth module (for now I think about HC-06), send that data stream through arduino mini pro to the output mini jack.

Do I need in that case some kind of mp3/other format decoder module like VS1003B on ebay ?