texts: Controlling VFD with ModBus RTU via RS485 and Arduino

texts:
I am attempting to control a Folinn VFD (Manual: Manual) with an Arduino Uno via a MAX485 module such as this.

Pins for MAX485:

DI > D8
DE & RE > D10
RO > D11

VFD settings:

F00.01 set to 2
F00.06 set to 9
F13.00 set to 1
F13.01 set to 5
F13.02 set to 3

At this stage I am attempting a very simple code just to turn the VFD on:

/*

   ModBus RTU control VFD

   Address               : 01H  (is the address of the VFD)
   Function              : 06H  (write function code)
   Starting data address : 20H
                         : 00H  (2000H  is the address of control command)
   Data(2Byte)           : 00H
                         : 01H  (0001H is forward command)
   CRC CHK Low           : 43H
   CRC CHK High          : CAH

*/

#include <SoftwareSerial.h>

#define SSerialRX        11  //Serial Receive pin
#define SSerialTX        8  //Serial Transmit pin
#define SSerialTxControl 10   //RS485 Direction control
#define RS485Transmit    HIGH
#define RS485Receive     LOW
#define Pin13LED         13

// From manual vfd Forward command = 01H 06H 2000H 0001H 43CAH

byte request1[] = {0x01, 0x06, 0x20, 0x00, 0x00, 0x01, 0x43, 0xCA};

SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX
byte byteSend;

void setup()
{
  // Start the built-in serial port, probably to Serial Monitor
  Serial.begin(9600);
  Serial.println("SerialRemote");  // Can be ignored

  pinMode(Pin13LED, OUTPUT);
  pinMode(SSerialTxControl, OUTPUT);

  // digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver

  RS485Serial.begin(9600);

}
void loop()
{
    digitalWrite(SSerialTxControl, RS485Transmit);
    RS485Serial.write(request1, sizeof(request1));

}

With the MAX485 connected to the correct ports (S+ and S-) on the VFD, this current setup receives no response is someone able to spot where I am going wrong? I have taken the values for CRC CHK Low & High from a different example, is this the issue?

Have also tried setting F00.01 to an unlisted '3' setting that I have seen pop up in other discussions but this made no difference. Any advice would be much appreciated, let me know if I can supply further details.

(I chose this method based on this example


texts: USB connector between Arduino and a lever (switch)

texts:
I am not sure an Arduino forum is the right place to ask this question, but since I'm using Arduino here I thought it would be a good starting point. I am trying to connect a lever (you can think of it as a switch, when it's pressed it's ON, and otherwise it's OFF) to an Arduino via a USB connector. My setup worked perfectly fine when I connected the lever directly to the Arduino, but via the USB it doesn't work. Since I already built and invested in USB connectors I would like to solve this issue, or at least understand what I am doing wrong in here.

I've attached a photo to demonstrate the wiring. Note that it works if I bypass this USB connection. I'm trying to understand why this doesn't work via a USB.


texts:
Update:

I've refactored the code to be very resilient to boards missing or not being able to talk to them. Then I tinkered with a bunch of pins and learned that it all comes down to the IOREF pin being connected to the USB Host shield or not. If it's connected, the USB shield "takes over", allows communication with it, but the CAN shield does not work. If the USB shield IOREF pin is not connected, but the rest of the shield's pins are, CAN works. If I disable the IOREF pin going into the CAN shield (and thus the USB shield also since it's on top), the CAN shield works fine still, but the USB shield does not.

Something happens when the IOREF is powered into the USB board and if it's not powered, you can't talk to it.

Original post:

I have the following setup:

Yourduino RoboRED board
Seeed CAN Bus Shield v1.2 http://wiki.seeed.cc/CAN-BUS_Shield_V1.2/
USB Host Shield https://www.arduino.cc/en/Main/ArduinoUSBHostShield

My issue is that if I connect only the CAN bus shield, I can initialize it without any problem, but when I connect the USB host shield on top of the CAN, the CAN shield becomes unresponsive.

I looked into the wiring and per the specs, the following is how the hardware is set up:

SPI bus runs on ICSP header for both shield, not on D11, D12 & D13. I could switch it for the CAN bus shield if I wanted/needed to, but I don't believe I shoudl be.
The trigger pin for the USB host is D10
The trigger pin for the CAN bus is D9 (since it's v1.2 of the board)
Both boards have power. USB board is on top since it does not have an ICSP male connector on the top side, only female on bottom.

I started to debug the code and traced down to this CAN bus function in mcp_can.cpp, which I've instrumented with debug:

INT8U MCP_CAN::mcp2515_setCANCTRL_Mode(const INT8U newmode)
{
    Serial.print("mcp2515_setCANCTRL_Mode with newmode = ");
    Serial.println(newmode);
    INT8U i;

    mcp2515_modifyRegister(MCP_CANCTRL, MODE_MASK, newmode);

    i = mcp2515_readRegister(MCP_CANCTRL);
    i &= MODE_MASK;
    Serial.println("i & MODE_MASK");
    Serial.println(i);
    Serial.println(MODE_MASK);

    if ( i == newmode )
    {
        return MCP2515_OK;
    }

    return MCP2515_FAIL;
}

The output when it fails is:

USB started ok
past SPI begin
mcp2515_init called
mcp2515_setCANCTRL_Mode with newmode = 128
i & MODE_MASK
0
224
Enter setting mode fall
res = 1

For reference, this is the mcp2515_modifyRegister function:

void MCP_CAN::mcp2515_modifyRegister(const INT8U address, const INT8U mask, const INT8U data)
{
    #ifdef SPI_HAS_TRANSACTION
        SPI_BEGIN();
    #endif
    MCP2515_SELECT();
    spi_readwrite(MCP_BITMOD);
    spi_readwrite(address);
    spi_readwrite(mask);
    spi_readwrite(data);
    MCP2515_UNSELECT();
    #ifdef SPI_HAS_TRANSACTION
        SPI_END();
    #endif
}

The whole file is here: https://github.com/Seeed-Studio/CAN_BUS_Shield/blob/master/mcp_can.cpp. I've tried setting SPI_HAS_TRANSACTION to true with no change in the outcome, though I also don't know exactly what this does.

This is my init:

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

    // init can bus : baudrate = 500k

    if (Usb.Init() == -1)
        Serial.println("OSC did not start.");
    else
        Serial.println("USB started ok");

    delay( 200 );

    while (CAN_OK != CAN.begin(CAN_500KBPS)) {
        Serial.println("CAN BUS Shield init fail");
        Serial.println(" Init CAN BUS Shield again");
        delay(10000);
    }

    Serial.println("CANbus ready");
}

It seems to have something to do with the registers available for write by the CAN bus library whenever the USB board is or isn't present. The write fails when the USB board is there. Any thoughts as to why or other things to try would be greatly appreciated.


texts: Arduino UNO Low-Power Consumption (Multiple Ultra-Sonic Sensors)

texts:
I've read post that it's possible to connect multiple Ultra-Sonic Sensors to one Arduino.
But I have a few questions:

If I use Arduino Uno, what is the maximum number of Ultra Sonic Sensors that I can connect one Arduino UNO?

Is there any option to power Arduino UNO in some kind of low-power mode so I can achieve power autonomy for at least 90 days.(I'm referring to battey life, or solar powered solutions)

Can Arduino UNO work on the low/high temperatures (e.g. -20 / +50 Celsius degrees), and what is the known work temperature range?

How to secure jumpers/cables to work on extreme temperatures (e.g. -20 / +50 Celsius degrees)
Thanks in advance :D


texts:
I new to Arduino and I'm attempting to writte a simple string compare code like this:

void loop()
{
  distance(cm);
  delay(200);
}

void distance(char[3] unit)
{
  if (unit[] == "cm")
    Serial.println("cm");
}

Could somebody please advise me how to writte it correctly?
Thanks in advance!


texts: How do I use an ATMega 328 (not P) chip with an Arduino board?

texts:
I just burned the bootloader on an ATMega328 chip and then I put in on the Arduino board. But when I try to upload a program to it, it says programmer not in sync and programmer not responding.

For burning the bootloader I changed the address in the avrconfig file and reset it back to the original one. Do I need to keep changing the address of the board?

How do I use this as a normal Arduino board, as I fried my original chip? Do I need to get an ATMega328P chip?


texts: Arduino as voltage monitor shorts to ground

texts:
I need to monitor voltages of several DC circuits in a generator's contact box.  Whenever the generator has an alarm, a LED is lit in the box and voltage on the line drops to zero.  I successfully get readings using analogRead(), but whenever I connect a line it shorts to ground (which is shared between the contact box and the Arduino) and triggers the contact box's alarm.  I need to devise a way to monitor voltages without triggering the alarm.

Each 5V line and ground from the generator has a bus bar termination point that connects to a point in the proprietary alarm box that houses the LEDs and buzzer. I connected Arduino ground to generator ground, then used A0-A7 on a Nano to connect to individual lines on the bus bar. Arduino VCC is connected to 5V regulated DC power.


texts: is it possible to interface two cameras with a single arduino board

texts:
I want to develop a project which has two cameras that can be controlled by Arduino,a range finder to get the distance of the objects that are captured by these cameras and the measured distance should be converted to acoustic signal that is audible by connecting ear phones to it.

The location where one is has to be identified by GPS.

So can I use a single Arduino board to interface this, or if not, please suggest any other way to implement it.


texts:
There is a problem running a simple SPIFFS file system code on different versions of the Arduino IDE, as code shown below. In Arduino IDE version 1.8.4, works fine. No longer version 1.8.9, can not run.
ESP8266
IDE Arduino version 1.8.9

#include <FS.h>

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

  // Always get ERROR on init SPIFFS
  if (!SPIFFS.begin()) {
    Serial.println("SPIFFS.begin error...");
  } else {
    Serial.println("SPIFFS.begin OK!");
  }
}


texts:
I'm using Arduino IDE for ESP32 WROOM board. I am testing the OTA feature with the ESP32httpUpdate library. I am using the example sketch of the library with the name httpUpdate.ino
However, as soon as I change the update url with a string pointer that I declare globally, it is throwing a compile error that String does not name a type. Any ideas?

/**
 * httpUpdate.ino
 *
 *  Created on: 27.11.2015
 *
 */
String* FIRMWARE_UPDATE_VERSION = "1000";

String* updateURL = "XYZ.php";

#include <Arduino.h>

#include <WiFi.h>

#include <HTTPClient.h>
#include <ESP32httpUpdate.h>

#define USE_SERIAL Serial

void setup() {

    USE_SERIAL.begin(115200);
    // USE_SERIAL.setDebugOutput(true);

    USE_SERIAL.println();
    USE_SERIAL.println();
    USE_SERIAL.println();

    for(uint8_t t = 4; t > 0; t--) {
        USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
        USE_SERIAL.flush();
        delay(1000);
    }

    WiFi.begin("SSID", "PASSWORD");

}

void loop() {
    // wait for WiFi connection
    Serial.println("Yolo");
    if((WiFi.status() == WL_CONNECTED)) {

        t_httpUpdate_return ret = ESPhttpUpdate.update(updateURL, FIRMWARE_UPDATE_VERSION);

        switch(ret) {
            case HTTP_UPDATE_FAILED:
                USE_SERIAL.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
                break;

            case HTTP_UPDATE_NO_UPDATES:
                USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
                break;

            case HTTP_UPDATE_OK:
                USE_SERIAL.println("HTTP_UPDATE_OK");
                break;
        }
    }
}


texts: Stop Arduino from powering LED strip when connected to USB

texts:
I have a WS2812B LED strip that is controlled by an Arduino. Normally, both the Arduino and LED strip are powered by the same 5V power supply. The 5V and GND pins of the Arduino and LED strip are connected together. If I want to reprogram the Arduino, I have to disconnect the LED strip or else it might want to try and draw power from my computer's USB.

I have a bunch of (assorted) transistors, (schottky, zener) diodes and resistors. Is there something I can build that will allow the power supply to power both the Arduino and LED strip, while the Arduino's USB can only power the Arduino itself?

I've thought about using a diode between the 5V of the Arduino and 5V of the power supply and using a resistor to pull the 5V terminal of the power supply pin low (when the power supply is not connected) but I'm not sure how stable that will be: once the diode starts conducting the resistor will have no chance to pull the pin low again and I'm not sure if the Arduino will like the voltage drop across the diode.

Obviously the external power would be disconnected before plugging the Arduino into USB. Since the LED strip runs on 5V I can't use the VIN pin.


texts: Global array doesn't get assigned the space it would take up in memory

texts:
I have this sketch:
const uint32_t len = 65536;
uint8_t arr[len];

void setup() {}

void loop() {}

The length of the array should fit into the dynamic memory. However, when I compile the sketch it says this in the output window:
Sketch uses 10528 bytes (0%) of program storage space. Maximum is 2031616 bytes.
Global variables use 13504 bytes (1%) of dynamic memory, leaving 1034224 bytes for local variables. Maximum is 1048576 bytes.

If I change len to 10, that doesn't change. The compiler is set to "Debug", so it should not get optimized away. This indicates, that the memory isn't actually being allocated. What seems to be the problem here?
I am compiling for the Teensy 4.0, but the output is the same in essence for the Arduino Uno and other boards (with lower memory sizes).


texts: Logging to multiple destinations (serial & SD card)

texts:
I am building a rover using an Arduino Mega and an Arduino Uno. The Mega has a sensor shield that has an SD card slot. The intent is for the rover to be autonomous, and I currently send logging info to the serial port (to log actions like boot, diagnostics, etc.)

Is there a simple way to redirect this output to BOTH the serial and the SD card? I would be happy with just a single file with lines added for each entry.

My complication here is to prevent using Serial.println as well as SD.println as two separate commands. Is there any other way around this?


texts: Getting inverse values of acceleration and tilt for the MPU 6050

texts:
I'm using the I2C library to connect to a GY-521 board and, when executing the getAcceleration() methods I get gyro values and viceversa..

This is my setup (I'm using a proto shield but that shouldn't change anything as far as I understand):

It follows this schematic:

And this is the code I'm testing:

#include "Wire.h"

#include "MPU6050.h"

MPU6050 accel;

int16_t ax, ay, az;

void setup() {
    Wire.begin();
    Serial.begin(9600);
    Serial.println("Initializing I2C devices...");
    accel.initialize();
    Serial.println("Testing device connections...");
    Serial.println(accel.testConnection() ? "Connected" : "Connection failed");
}

void loop() {
    accel.getAcceleration(&ax, &ay, &az);
    Serial.print("acc x:    ");
    Serial.println(ax);  // This prints the gyro value of the Y axis!
    delay(1000);
}

I don't think it has to do with the wiring since inverting the 4 and 5 analog pins yields zero values.

Is this a problem with the library? Or with my chip?


texts: Implementation help with difference equation

texts:
Implement the below difference equation
Y[n]=04142y[n-1]+0.2929(x[n-1])
Assuming an implementation
sampling frequency of 8khz
any help with code would be great :)


texts:
I am thinking about buying Arduino or Raspberry Pi.  I generally know Arduino advantages (fast start-up, low consumption, ADC converters) and disadvantages (low memory, low connectivity, hard programming), but I simply cannot figure out maybe the most important issue: current output for controlling devices.

One of the common cited advantages of Arduino system compared to Raspberry Pi system is that power per I/O pin is much larger.  Arduino Uno allegedly has up to 20 mA @ 5 V per pin and 50 mA @ 3.3 V per pin making quite substantial power of 0.15 W, compared to say typical 10 mA @ 5 V per pin for Raspberry Pi (although there is no official number available).

On the other hand

this power is far too low to control any motors and you still have to
provide shields,
new version Arduino 101 reduced that current to 20 mA and even less for some other Arduino models.

So, what is really the importance (if any) of these higher currents for home projects, compared between different Arduinos themselves and compared to Raspberry Pi?

There is also a question of total current for all pins together, which is also limited, but it is soooooo difficult to get official limits (for both Arduino and Raspberry Pi).

Please give me some insight into this issue, so I can decide.


texts: How to upload arduino code using xbee module ( pro s2c)?

texts: I have three arduino ATMega2560 boards, all have xbee pro s2c attached to them. Now i want to update the code i had previously written on the arduino board but without connecting it to the computer. So basically I want to upload a code to arduino board via the xbee module I have attached to it, code is transmitted to this xbee from another xbee. Anyone with any type of ideas please share....


texts: Getting random values on Arduino Duemilanove 328

texts:
I am using Arduino Duemilanove 328,and running the AnalogReadSerial example sketch.

Even when nothing is connected to the Arduino board it still shows a value of about 350 out of 1023. Ideally it should have shown 0 out of 1023 when nothing is connected to Arduino.

So how can I solve this problem?


texts:
I want to create an Arduino based vehicle tracking device which will be moved into a production board without Arduino later. Right now I have a few questions:

What GPS module should I use for a best result (little time to fix from a cold start and high accuracy locations)? It will be good if support GLONASS. I want to detect when the car is turning (using HMC5983). I've bought Ublox NEO-6M GPS module and tested it into the car, but it cannot find a location.
What MCU I should buy? I also want to communicate with OBD II port of vehicle over the CAN protocol (using MCP2551 + MCP2515). For now i choose ATMega328.
How to power all elements ?

PS: Data from the vehicle and the GPS locations will be send over GPRS with SIM800l module.

Cheers


texts: espcomm_sync failed when connecting ESP8266 (ESP-01)

texts:
I'm new to the Arduino (I'm a developer but didn't have a chance to work with this kind of device before) and wanted to connect my ESP8266 to the Arduino Uno. I followed this tutorial but I got errors:

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_memfailed
error: espcomm_upload_mem_failed

I tried running WiFiScan from the examples. I've installed SiLabsUSB Driver (I'm on macOS) and tried different solutions across the internet and I couldn't make it work.
There are screenshots of the settings.


texts:
I'm completely new to using modules for the Arduino, so I'm sure some people have more knowledge about this topic than me.
Here's the thing, I want to stream audio over my home wifi, so I'm in need of some rather high-speed modules, I'm aiming for 1-1.5 mbps for some proper compressed audio, including the overhead.

I've looked online for some well known wifi modules, but the only one I've managed to find that is popular is the esp8266, and that thing is definitely not for streaming anything.

Before anyone asks, yes, it is critical for it to work over wifi.
Has anyone done something like this? What gets the best results?


texts: Value of the counter collide on my lcd while decreasing. How can I remove it?

texts:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
int visitor=0;  //variable for counting visitor number

unsigned long timer_1,timer_2;  //variables for recording time for ir_1 and ir_2

void setup() {
   lcd.begin(20,4);
   pinMode(A0,INPUT);
   pinMode(A1,INPUT);
}

void loop(){
 lcd.setCursor(0,4);
   lcd.print("visitor=");
   lcd.setCursor(8, 4);

   lcd.print(visitor);

   if(digitalRead(A0)==1 && digitalRead(A1)==0)
  {
    timer_1= millis();
  }
  if(digitalRead(A0)==0 && digitalRead(A1)==1)
  {
    timer_2= millis();
  }
  if(timer_1>timer_2)
  {
   lcd.setCursor(8,4);
   visitor=visitor+1;
   lcd.print(visitor);
   delay(2000);
   timer_1=0;
   timer_2=0;
  }
 else if(timer_1<timer_2)
  {
   lcd.setCursor(8,4);
   visitor=visitor-1;
    if (visitor<=0)
  {
    visitor=0;
  }
   lcd.print(visitor);
   delay(2000);
   timer_1=0;
   timer_2=0;

  }

}

Two IR sensors are placed in A0 and A1.

While the value of visitor is decreasing from 10 to 9 the LCD is showing 90 because  the '0' of previous 10 is here. How can I remove it?


texts: How can I power an Arduino in a 3-phase environment?

texts: I am working on a project which uses an Arduino board. Currently I am testing my device using 2-phase power and it works fine.  I want to use that device in agriculture fields where 3-phase power is available instead. How can I do this?


texts:
I want to make a single cell 3×2 Braille grid that has 6 up and down shafts each of which can be controlled by arduino using 6 stepper motors .

So will that work with 1 arduino uno and/or stepper driver?
How many drivers should I use or is there a better way for controlling those 6 up down shafts individually?
Can I use 16 channel servo shield for controlling those stepper motors?


texts: Signal sampling: losing data every 103 points when it is recorded in SD

texts:
I'm working on a system of acquisition and ECG datalogging with the Arduino, and I'm having the following problem:
I'm losing data every 103 points (just 103). No matter the sampling frequency to use, every 103 points, some points are lost, damaging the signal sampling.
It could be the recording time on the SD card, but even when the SD.close () command is run only once, the data is lost.
Here is a simple test algorithm with a 100 Hz sine wave at the entrance.

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

int CS = 4;
int ECG_PIN = 1;
int voltage;

int index = 0;
const int bufferSize = 5;
int vetor[bufferSize];
int RECORD_TIME = 20000;
File logFile;

void setup(){
  pinMode(CS, OUTPUT);
  pinMode(ECG_PIN,INPUT);

  if(!SD.begin(CS)){
    return;
  }
  logFile = SD.open("ECG_log.txt", O_CREAT | O_WRITE);

}

void loop(){
  while(millis() <= RECORD_TIME){

      voltage = analogRead(ECG_PIN);
    if(logFile){

       logFile.println(voltage);

       delay(0.5);
    }
  }
  logFile.close();
}

What could it be? Speed analogRead ()? Problem on the SD card?

Sorry if the question is very basic, I am beginner, in a way, the Arduino platform. Any help will be very welcome.

Thanks!...


texts: How to call more than 10 different functions based on serial input?

texts:
I'm looking to basically call functions based on the serial ID I assign to it. For example, if I want to call function A I would type on the serial A and if I want to call function B then I would type B.

Now I have taken a look at some arduino.cc ASCII and other lookup tables but I'm still not getting my results. YES I can indeed make up serial calls 1 through 9 using char datatype but as you can see I'm only limited to 9 function calls and so this is where I'm looking for tips. How can I expand this serial ID as I'm calling it?

char id;
int led = 6; // the PWM pin the LED is attached to

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

void loop() {
  id = Serial.read();
  /*
    will only read the 1st bit on the buffer so
    no 10s...90s because the whole char so we
    need to use Strings datatype somehow but
    the thing is that the Serial.Read func only
    reads the first byte. R&D?
  */
  if (id == '1') {
    digitalWrite(led, HIGH);
  } else if (id == '2') {
    digitalWrite(led, LOW);
  }
}

So in my above example I'm using char to communicate. I know there are other datatypes but not sure which is the best suited for the 100's of functions I would like to call via terminal.

I thought about using the alphabet A-Z as well as a-z to double the function calls but I would like to come up with something a bit more formal rather than single numbers or single letters (char).


texts:
I'm very new with this devices so I'm a bit confused. I've got two Xbee modules series 1 and an Arduino UNO. I want to make like a chat between the two Xbee modules, one of them connected to the PC through a Xbee Explorer USB and the other one assembled in the Arduino Board through a shield.

I've configured the two Xbee modules with the same PAN ID and Channel, and the Xbee module 1 has MY = 0 and DL = 1 and the Xbee module 2 has MY = 1 and DL =0.

I've connected the Xbee module 1 to the PC through the Explorer and the Xbee module 2 connected to the PC through Ardunino+Shield.
I've uploaded the following code to Arduino:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(4, 5); // RX, TX

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

  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

In my shield the jumper of the RX digital is the 4th pin and the TX jumper in the 5th pin.

When I open the serial monitor window I get the message "Goodnight moon!" but when I send a message from the XCTU console or from the serial window I don't get that message in the other interface (XCTU console or serial monitor window).

In the shield (this one http://www.seeedstudio.com/wiki/XBee_Shield_V2.0) I've 4 leds: first one (power) is on, the second one (signal strength) is off, the third one (association) blinks all the time, and the fourth one (on/sleep) is on.

Why I don't get the messages like a chat? What am I missing?

Thank you!!


texts: How to increase Arduino's memory to save Dot Matrix Library?

texts:
I need to display some dynamic Chinese characters to 12864 using Arduino. What to show is transported from my web server. The character is stored as a 16x16 dot matrix, needing 16*16/8=32 byte. And I need to show some sentences, which contains more than 100 Chinese characters.

The problem is that I can't storage all the dot matrix data in Arduino because it has too small memory.

If I get the dot matrix data from web server, I need to have 100*32B memory, but SPAM with EEPROM have only 3k. So that failed.
If I save the dot matrix "library" in the Flash memory, I need 3500*32B (There are 3500 Chinese frequent-used characters), but there is only 32K Flash. Saving the "library" means that I should storage the dot matrix data of all the 3500 chars in Flash, then the server only need to send the Unicode of characters, and I can get the matrix of the char.

Any help is appreciated!


texts:
this is my method

void mensaje_sms()
{
  string numero = "777777";  // this is my variable
  SIM900.print("AT+CMGF=1\r");
  delay(100);
      SIM900.println("AT+CMGS=\"591"numero"\"");
//IM900.println("AT+CMGS=\"59177777777\""); //only in this way does it work
      delay(100);
      SIM900.println("SEND NUMERO VARIABLE RODO");
      delay(100);
      SIM900.println((char)26);
      delay(100);
      SIM900.println();
      delay(5000);
      Serial.println("SMS sent successfully");
    }

how can I send a variable to println?


texts:
My project is based on a moving fan using DHT11 sensors. I have used 2 void loops and the IDE is showing an error

  "exit status 1
  redefinition of 'void loop()'"

One doubt: Can we use 2 void loops in the code? Please see and identify the errors.

2nd doubt: dht DHT; shows error

  "exit status 1
  'dht' does not name a type" for my version of Arduino 1.8.1

#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>

 // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define dht_dpin 12
dht DHT;
#define pwm 9

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  lcd.clear();
  lcd.print(" Fan Speed");
  lcd.setCursor(0,1);
  lcd.print(" Controlling");
  delay(2000);
  analogWrite(pwm, 255);
  lcd.clear();
  lcd.print("Circuit Digest ");
  delay(2000);
}

void loop() {
  DHT.read11(dht_dpin);
  int temp=DHT.temperature;
  lcd.setCursor(0,0);
  lcd.print("Temperature:");
  lcd.print(temp);   // Printing temperature on LCD
  lcd.print("oC");
  lcd.setCursor(0,1);
  if(temp <26 ) {
    analogWrite(9,0);
    lcd.print("Fan OFF");
    delay(100);
  } else if(temp==26) {
    analogWrite(pwm, 51);
    lcd.print("Fan Speed: 20%");
    delay(100);
  } else if(temp==27) {
    analogWrite(pwm, 102);
    lcd.print("Fan Speed: 40%");
    delay(100);
  } else if(temp==28) {
    analogWrite(pwm, 153);
    lcd.print("Fan Speed: 60%");
    delay(100);
  } else if(temp==29) {
    analogWrite(pwm, 204);
    lcd.print("Fan Speed: 80%");
    delay(100);
  } else if(temp>29) {
    analogWrite(pwm, 255);
    lcd.print("Fan Speed: 100%");
    delay(100);
  }
  delay(3000);
}
}


texts: Decimal numbers sent over Serial get split and sent over multiple ticks

texts:
Here is my Arduino sketch:

#include <HX711.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
HX711 hx(9, 10, 128, 0.002229);
LiquidCrystal_I2C lcd(0x27,16,2);

void setup() {

  Serial.begin(9600);
  hx.set_offset(-9635);
  lcd.init();                      // initialize the lcd
  lcd.backlight();
  lcd.begin(16,2);

}
void loop() {
  if(digitalRead(0) == LOW){
    lcd.clear();
    lcd.setCursor(2,0);
    lcd.print("tare recieved");
    hx.tare();
  }

  double sum = 0;
  for (int i = 0; i < 10; i++) {
    sum += hx.bias_read();
    if(sum < 0) {
      sum = 0.00;
    }

  }
  sum = sum/10;
  lcd.clear();
  lcd.setCursor(4,0);
  lcd.print("Weight");
  lcd.setCursor(5, 1);
  lcd.print(sum);
  lcd.print("g");
  Serial.println(sum);
  delay(10);
 }

Here is an example output as seen on the Arduino Serial Monitor:

150.34
150.39
150.40
150.37
150.38

The Problem is when the data reaches node-serialport the value is split up on multiple lines.

 comport.on("data", function (data) {
    console.log(data.toString());
 }

When i log the data... it comes back like this:

1
50.4
5
150.
49
15
0.47
150.
48
15
0.45

Is there anyway to have Arduino only send the data if it is the full value and not the split up values?


texts: How to wire and use a B10K linear LED potentiometer?

texts:
I've bought some nice looking LED potentiometers from Ebay. They look like this.
I'm very new to low level electronics/hardware and I don't know how to wire it. It has 4+2 pins.
Also, how to use it in the Arduino?


texts: Unexplained behavior of char array after using `deserializeJson`

texts:
I'm using RF24 library to send messages between 2 MCU's : 1) ESP8266 (no Wifi, same code can be compiled to any Arduino board) 2) pro-Micro.
Message is sent in JSON format, while using ArduinoJSON library to serialize and deserialize messages.
Altough entire code works as expected, I get an error in "RFread" function, which _readmsg array loses its content after using deserializeJson.
Attached below  relevant part of "RFread" function. Explanations in code below. Please notice "Mark [X]" in code and Serial output:
char _readmsg[32];                                <---- Storing input in this array
    char t2[32];                                  <---- variable to clone value
    radio.read(&_readmsg, sizeof(_readmsg));      <---- getting RF input and store it in `_readmsg`
    strcpy(t2, _readmsg);                         <---- cloning, part of error seeking

    Serial.print("first: ");                      <---- printing initial value stored. OK. marked [A] in Serial output
    Serial.println(_readmsg);
    Serial.print("duplicate: ");                  <---- printing clone. OK. marked [B] in Serial output
    Serial.println(t2);

    if (key != nullptr)                           <--- check if "msg" key was sent in message
    {
      StaticJsonDocument<80> DOC;
      deserializeJson(DOC, _readmsg);             <---- **error beyond this point**
      Serial.print("second: ");
      Serial.println(_readmsg);                   <---- printing wrong value. marked [C] in Serial output

      if (DOC.containsKey(key))
      {
        const char *outmsg = DOC[key];
        if (out != nullptr)
        {
          strcpy(out, outmsg);
          return true;
        }
      }
      else
      {
        Serial.print("third: ");
        Serial.println(_readmsg);              <---- still error. marked [D] in Serial output
        Serial.print("duplicate2: ");
        Serial.println(t2);                    <---- clone variable is OK. marked [E] in Serial output
        strcpy(out, t2); // if key not present, return entire message
        return 0;
      }

and in Serial port:
message sent OK   <---- irrelevant for debug

15:18:14.934 -> first: {"id":"Port","msg":"fff"}       <----[A]

15:18:14.934 -> duplicate: {"id":"Port","msg":"fff"}   <----[B]

15:18:14.934 -> second: id                             <----[C]

15:18:14.934 -> third: id                              <----[D]

15:18:14.934 -> duplicate2: {"id":"Port","msg":"fff"}  <----[E]

15:18:14.934 -> Error. no such key. got reply: {"id":"Port","msg":"fff"}

Is there a reason for that ? is it a bug ?


texts:
I have connected a bluetooth module(HC-06) and a voice recognition shield(EasyVR) on an arduino UNO.
By using an another HC-06 on the another arduino(so, 2 arduinos and 2 HC-06 totally), I am going to let two arduionos communicate with each other.
Also, simultaneously, one arduino with HC-06 will recogize the voice by using the voice recognition module.
I have successed each operations, but after combining two codes the bluetooth doesn't work...
(Voice recognition have successed.)

Is it unable to operate two operations simultaneously?

Can we use these two sentences in one code?
SoftwareSerial BT(2,3);     --> for bluetooth module
SoftwareSerial Port(12,13);   --> for voice recognition module


texts: Is there an all in one circuit which regulates charging, protects and steps up/down an 18650 battery to 12V and 3.3V at the same time, so I can power a sensor and my ESP32?


texts: Servo problem when use gps with softwareserial

texts: When I use together servo motor and gps module with softwareserial , I found problem .Servo turing without signal.When I remove gps receive pin ,servo normally work. I use arduino mega 2560, ublox NEO6M and micro servo SG90 .Help me please!


texts: How can I compare two serial port readings on Arduino Mega?

texts:
I'm writing some code that compares information from two Arduino Unos by an Arduino Mega 2560. The problem that I'm having is that when I read the information coming in through Serial1 and Serial2 on my if statements, I get both inputs out on my serial monitor for the Mega, but if I try to compare them after I have read them it comes out not working the way it is intended. I don't know if I might be missing some syntax on my code or if I'm doing this wrong but I would appreciate any help I can get.

byte inData;

byte inDataTwo;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial2.begin(9600);

  while (!Serial)
  {
    ; // wait for serial port to connect. Needed for native USB port only
  }
}

void loop()
{
  if (Serial1.available()>0 )
  {
      inData = Serial1.read();
      Serial.print(char(inData));
  }
  if (Serial2.available()>0)
  {
    inDataTwo = Serial2.read();
    Serial.print(char(inDataTwo));
  }
  if(inData == inDataTwo)
  {
    Serial.print("true");
  }
  else
  {
    Serial.print("False");
  }
}`


texts: Is it possible to overclock the baudrate from the mega to 230400 bps?

texts:
i have a Arduino Mega 2560 and want send data with 230400bps to my laptop without any framingerror.

I want send the data over USB with serial.print ist that possible or must i use the ethernet?

When that is possible it will be really nice when someone can write what i have to do.

With friendly wishes sniffi


texts: ArbotiX-M Problem uploading to the board

texts:
I have an ArbotiX-m Arduino board, and have followed the setup guide on Trossen robotics all the way to the 5th step. I have a Mac running OS X 10.10 and use Arduino 1.0.5. I installed the necessary drivers and copied the files to the Sketchbook directory. When I try to load the sample ArbotiXBlink program:

// Pin 0 maps to the USER LED on the ArbotiX Robocontroller.
int led = 0;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

It verifies just fine, but when I click upload, I get:

Binary sketch size: 1,088 bytes (of a 65,536 byte maximum)
avrdude: stk500_recv(): programmer is not responding

Any ideas?

EDIT: The board was trying to get power from the 5V instead of USB


texts: Arduino Upgrading from 1.0.6 to 1.6, code doesn't work anymore

texts:
I'm using Arduino UNO, and today I upgraded my IDE from 1.0.6 to 1.6, just to upgrade, nothing special.

I got my libraries again but I got an error with a code that was working OK.

The error was:

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:223:0,
                 from C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.h:53,
                 from C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.cpp:32:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h: In member function 'HardwareSerial& HardwareSerial::operator=(const HardwareSerial&)':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ubrrh', can't use default assignment operator
 class HardwareSerial : public Stream
       ^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ubrrl', can't use default assignment operator
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ucsra', can't use default assignment operator
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ucsrb', can't use default assignment operator
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_ucsrc', can't use default assignment operator
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:83:7: error: non-static const member 'volatile uint8_t* const HardwareSerial::_udr', can't use default assignment operator
C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.cpp: In member function 'void ModbusMaster::begin(uint16_t)':
C:\Program Files (x86)\Arduino\libraries\ModbusMaster-master\ModbusMaster.cpp:139:16: note: synthesized method 'HardwareSerial& HardwareSerial::operator=(const HardwareSerial&)' first required here
       MBSerial = Serial;
                ^

I couldn't find the real error, can someone help me?


texts: The difference between "time_t" and "DateTime"

texts:
I've run into an issue trying to combine 2 different Arduino timer projects I've found online.

For both projects I'm using a DS3231 RTC, but have been able use the DS1307 library just fine in my code.

The first set of code I picked up started with:

#include <DS1307RTC.h>

The second set of code I tried to combine did not have this 'include', but instead used

RTC_DS1307 RTC;

as found here:

https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/understanding-the-code

As a novice coder, I'm not really sure what the difference between the above two ways to call this library. But I do know the first way using "include", if I want to access the current time on the RTC I use

RTC.get();

as opposed to the second method which requires:

RTC.now();

And while it was easy to find documentation to sync the RTC to computer time over the USB cable using this handy bit of code:

// Notify if the RTC isn't running
    if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running");
  }

   // Get time from RTC
  DateTime current = RTC.get();
  DateTime compiled = DateTime(__DATE__, __TIME__);
  if (current.unixtime() < compiled.unixtime()) { //CHECKS AGAINST COMPUTERTIME
    Serial.println("RTC is older than compile time! Updating");
    RTC.adjust(DateTime(__DATE__, __TIME__));  //UPDATES FROM COMPUTER IF OLD TIME IS OFF
  }

I can find no easy alternative using "#include DS1307RTC"

I first thought that the difference between RTC.now() and RTC.get() was just a matter of word substitution. But later on when I want to use a "time_t" call after initializing with "RTC_DS1307 RTC;"

 time_t timeNOW = RTC.now();

I get the error "cannot convert 'DateTime' to 'time_t {aka long unsigned int}' in initialization"

So I'm assuming one method uses "DateTime" and one method uses "time_t". But I'm not sure if this is the case, and if so, how to convert a "DateTime" value to a "time_t" value.

I have two goals in writing this post.

1- Can someone please explain to me the difference between "#include DS1307RTC.h" and "RTC_DS1307 RTC;" and how it impacts my code.

2- I'd like to stick with using ""RTC_DS1307 RTC;", only because it seems easy to sync my RTC to my computer. But if I do, I get the above error. So can someone please tell me how to convert a "RTC now()" call to a "time_t" value? Or is the issue more complicated than just a mere conversion between data types?


texts: Starting DC Pump with Arduinowhen it is powered by 9v Battery

texts:
I'm using Arduino Mega, and would like to start a DC Motor Pump. In my circuit, there are several sensors that are going to take up the voltage offered by Mega.
Hence, I would like to know whether there is a way to control the working (start/stop) of the pump using arduino as the controller while the motor being powered by a 9V battery.


texts: Is it safe to short two pins together for conditioning a sketch?

texts:
I want to make a sketch which behaves differently, i.e.:

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

pinMode(pin2, OUTPUT);
digitalWrite(pin2, LOW);

pinMode(pin3, INPUT);
// And a user decides to short pin3 with pin1 or pin2

if (digitalRead(pin3) == HIGH) {
  // behavior 1
} else {
  // behavior 2
}

But, I wonder whether shorting two pins with/without a resistor safe or not. If it is dangerous, what is an alternative way to do such a thing?


texts:
Does the Arduino Yun does it have a RTC?

And if so is it connected to the Atheros AR9331 or the ATmega32u4?

If there there is no RTC, can I connect a DS1307 to the Atheros AR9331?


texts: How can I make a rotary encoder change between neopixel programs?

texts:
I am making a program to use a rotary encoder instead of a button in the buttoncycler example in the Adafruit NeoPixel library.

I am using the US Digital S1-256-250-IE-B-D. Datasheet can be found here: https://cdn.usdigital.com/assets/datasheets/S1_datasheet.pdf?k=636466553771569761

#include < RotaryEncoder.h >
void setup() {
}
void loop() {
  static int change =  0;
  static int pos = 0;
  static int oldPos = 0;
  //Read the Encoder's state
  encoder.tick();
  int enc = encoder.getPosition();
  pos = abs(enc) % 2;
  change = oldPos-pos;
  if (change != 0) {

    switch (pos) {
      case 0:
      //do a program that lasts 5 seconds
      break;
      case 1:
      //do a program that lasts 5 seconds
      break;
    }
    oldPos = pos;
    change = 0;
  }
}

I was wondering if there is a way to change the program immediately after turning the rotary encoder, instead of having to wait for the program to complete.


texts: What components do I need to build Arduino based water pump controller?

texts:
I have situation at my home which is causing us a lot of headache. We get drinking water only at midnight and someone has to wake up and switch on electric pump. This electric pump will pump water from water tank present at ground floor to the water tank present on the terrace.

I want to automate this electric pump operation and I have come up with following rules for it:

When water tank at ground floor is almost full then automatically turn on the pump which will push water from ground floor to the tank on the terrace.
When water tank on the terrace is full then switch off motor.

I am a professional software engineer and I have vast experience in Java, Scala, REST API, Big Data and all but I am totally new to Arduino so I do not know which Arduino components I need to build the above mentioned system.

Any guidance will be deeply appreciated.

Thanks,
Chandra


texts:
I am having trouble with my digital sound sensor.  My goal: Clap 2 times and a led goes on. So I wrote this code. I don't know if it is correct or not. This happens: If I clap, from the serial monitor I don't get one HIGH, but a few (I tried changing the sensitivity of the soundsensor, but it doesn't help), but in my code I have some conditions where only 1 HIGH at a time is allowed. Thus, I don't know if my code is incorrect, or my sensor isn't working well.  Can you guys help me please? This is my code:

int soundPin = 13;             // Digital soundPin
int ledPin = 7;
int claps = 0;                 // The amount of times I clapped
int readingState ;             // The first reading from the soundPin
int readingState2 ;            // The second reading from the soundPin
int soundDetectionTime ;       // The time after the first clap
int soundDetectionTime2 ;      // The time after the second clap
int timeBetweenSounds = 1000;  // The time between the sounds I want. There
                                  is an If-statement further on.

void setup(){
  pinMode(soundPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  readingState = digitalRead(soundPin);    // The first reading form the
                                              soundPin (digital pin)

  Serial.println(readingState);

  if (readingState == HIGH){               // If the reading from the
                                             soundPin is HIGH, then start
                                             timing. Also claps value
                                             increased by 1 and the
                                             second reading is happening.
    soundDetectionTime = millis();
    claps++ ;
    readingState2 = digitalRead(soundPin);

      if (readingState2 == HIGH){          // If the above statement is
                                              true, then this if-statement
                                              is executed. If the second
                                              reading is HIGH,
                                              soundDetectionTime two will
                                              start counting
    soundDetectionTime2 = millis();    // Also the claps get increased by 1,
                                          so now claps = 2.
        claps++;
   }
   }

   if ((soundDetectionTime - soundDetectionTime2) > timeBetweenSounds &&
claps==2){                            // If there is 1 second between the
                                         two readings and if I clapped
                                         twice, then LED is HIGH.
    digitalWrite(ledPin, HIGH);
   }
   }

UPDATE: I managed to get two HIGHs seperate from each other and the led is now on. So the problem must be the sensor giving me too much HIGHs if I clap once, like: 0,0,0,0,1,1,1,0,0. What do you guys think?


texts:
As similar to ESP32/ESP8266 that can put asleep for long periods of time, I'm looking for a way to put a Pro-Micro to sleep for more than 8 seconds ( no external interrupt , or RTC ), as used in LowPower.h library.
Appreciate any help.
Edit1: Usage - send sensor reading from a remote location. I'll be solar+battery powered device, so I need to keep power consumption as low as possible.


texts: How to pass a filename to a function? What type of variable is the filename?

texts:
In the example below, I have two functions that write numbers to two different files on an SD card. I'm using the SdFat library.

Is there any way I can combine the two functions into one, so that I can call (for example): writeToFile(int t, FileName "filename1.txt");?

In the example below, to write a value to the "temperature.txt" file, I would like to be able to call: writeToFile(7, "temperature.txt"); In my sketch I have about a dozen functions that are writing to a dozen different files, so it would be very handy to be able to combine them into one function.

I think the main part I'm stuck on is I have no idea what the filename variable would be, or how to pass the filename to the function.

#include <SdFat.h>
SdFat sd;

void setup() {
  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {
    sd.initErrorHalt();
  }

  setTemperature(7);
  setFanSpeed(4);
}

void setTemperature(int t) {
  SdFile rdfile("temperature.txt", O_WRITE);
  rdfile.rewind();
  rdfile.println(t);
  rdfile.close();
}

void setFanSpeed(int t) {
  SdFile rdfile("fanspeed.txt", O_WRITE);
  rdfile.rewind();
  rdfile.println(t);
  rdfile.close();
}


texts: MPU6050: Setting Gyro Output Range Throws of Positional Reading

texts:
I am using the MPU6050 in conjunction with an Arduino and Jeff Rowberg's i2cdev library, and my project requires that the gyro rate outputs be more precise than the default setting, which is 1/16.4 of a degree (+/-2000 deg/sec range). The gyro outputs can be changed with mpu.setFullScaleGyroRange(uint8_t range) for which I passed in MPU6050_GYO_FS_500 for range to get a higher precision

In this project, I also need the YPR position, which I obtain through mpu.dmpGetQuaternion(&q, fifoBuffer) and mpu.dmpGetGravity(&gravity, &q) and mpu.dmpGetYawPitchRoll(ypr, &q, &gravity).

The problem is with the new gyro output range, the YPR position changes drastically when the MPU is being rotated and slowly catches up again once the MPU is held still. I think there is an error in the filter that combines the gyro and accel data that is making the gyro to sensitive. Maybe the DMP is dividing the GYRO rate data by the default sensitivity factor (16.4) when it should be dividing by the new one (131)?

How can I get accurate YPR readings without delay?

Here is a screenshot of the data. The axis aren't labeled, but the x-axis represents about 16 seconds of time. The blue line is the gyro rate data, and the pink line is the roll position of the MPU. The graph shows two rotations of the MPU.


texts: Using RFID and fingerprint sensor together

texts:
I am using both an RFID and a fingerprint sensor in my project. When running the program, the RFID is detected but the fingerprint sensor is not detected and hence my code is not going forward.

Here is my code

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <MFRC522.h>
#include <SPI.h>

#define SAD 10
#define RST 5
MFRC522 nfc(SAD, RST);

uint8_t id;
uint8_t getFingerprintEnroll();
int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
SoftwareSerial mySerial(2, 3);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup() {
   SPI.begin();
   Serial.begin(115200);
    Serial.println("Looking for MFRC522.");
   nfc.begin();
   byte version = nfc.getFirmwareVersion();
  if (! version) {
    Serial.print("Didn't find MFRC522 board.");
    while (1); //halt
  }

  Serial.print("Found chip MFRC522 ");
  Serial.print("Firmware ver. 0x");
  Serial.print(version, HEX);
  Serial.println(".");
  Serial.begin(9600);

  Serial.println("Fingerprint and RFID Test");

  finger.begin(57600);
  if (finger.verifyPassword()) {
   Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }
}

char abc;
void loop() {
    abc = Serial.read();
    switch (abc) {
      case '1': {
             //Enroll method
      }
      break ;
      case '2': {
        //verify method
      }break;
      case '3': {
       //rfid method
      }
   }
}


texts: Problems using an arduino with vex motors and motor controller 29

texts:
I am using a VEX 2-wire motor with the Motor Controller 29 to use it like a three-wire motor.

I was told that I am able to program it like a servo using the Arduino Servo class. When I use the write() function to set the power, it works from values around 50-85 in one direction, slowing down the power as I increase the value, but when the value exceeds around 90 then the motor stops working and makes strange clicking sounds. It is not a hardware problem, because the motor works fine in either direction when I plug it straight into a power source.

Does anyone know what my problem is?


texts:
I'm using an MPU-6050 chip in order to calculate orientation. It is connected to an Arduino Pro Mini. I am using code written by Jeff Rowberg that uses the internal DMP. The 57600 baud rate crashes the sketch after a minute, so I changed it to 9600. Setting TWBR to 14 did nothing. I also modified the MPU6050_6Axis_MotionApps20.h file in order to decrease the FIFO rate. It didn't really help. Here's some sample output when the sensor is lying stationary on a desk:

0.80:-4.15:64.50
0.80:-4.15:64.51
0.80:-4.15:64.51
0.80:-4.15:64.51
0.80:-4.15:64.51
0.80:-4.15:64.51
0.80:-4.15:64.51
0.80:-4.15:64.51
0.80:-4.15:64.51
0.80:-4.15:64.50
0.80:-4.15:64.50
FIFO overflow!
0.81:-4.15:64.50
0.81:-4.15:64.50

I suppose that FIFO overflow doesn't bother me that much, but in my opinion, it's inefficient. I'm not sure what I'm doing wrong that causes the FIFO overflow. Any ideas?

Edit 1:
Code

#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
MPU6050 mpu;
bool dmpReady = false;
uint8_t mpuIntStatus, devStatus;
uint16_t packetSize, fifoCount;
uint8_t fifoBuffer[64];
Quaternion q;
VectorFloat gravity;
float euler[3], ypr[3], py, pp, pr;
unsigned long last_read_time;
int16_t ax, ay, az, gx, gy, gz;
char dataOut[256];
volatile bool mpuInterrupt = false;
void dmpDataReady() {
  mpuInterrupt = true;
}
void setup() {
  Wire.begin();
  //TWBR = 12;
  Serial.begin(9600);
  mpu.initialize();
  mpu.testConnection();
  mpu.dmpInitialize();
  mpu.setDMPEnabled(true);
  attachInterrupt(0, dmpDataReady, RISING);
  mpuIntStatus = mpu.getIntStatus();
  dmpReady = true;
  packetSize = mpu.dmpGetFIFOPacketSize();
}
void loop() {
  const float RADIANS_TO_DEGREES = 57.2958;
  if (!dmpReady) return;
  unsigned long t_now = millis();
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  while (!mpuInterrupt && fifoCount < packetSize) {
    mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
    unsigned long t_now = millis();
  }
  mpuInterrupt = false;
  mpuIntStatus = mpu.getIntStatus();
  fifoCount = mpu.getFIFOCount();
  if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
    mpu.resetFIFO();
    Serial.println(F("FIFO overflow!"));
  } else if (mpuIntStatus & 0x02) {
    while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
    mpu.getFIFOBytes(fifoBuffer, packetSize);
    fifoCount -= packetSize;
    mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
    Serial.print(ypr[2]*RADIANS_TO_DEGREES, 2);
    Serial.print(":");
    Serial.print(ypr[1]*RADIANS_TO_DEGREES, 2);
    Serial.print(":");
    Serial.println(ypr[0]*RADIANS_TO_DEGREES, 2);
  }
}

SDA is wired to A4

SCL is wired to A5

INT is connected to Pin 2

The data is usually surprisingly stabile, only differing by 0.01 degrees per reading. However, sometimes, there'll be one reading that is unlike all previous and following readings.


texts: How to recover an I2C bus when SDA is stuck low? Edit: SDA line stuck high

texts:
See edit at the end of the message.

I have an Arduino in master mode connected via I2c to a slave, with 2k pull-up resistors on SDA and SCL. Sometimes the SDA line is stuck low, which causes my program to hang indefinitely.

How to recover from such a scenario?

Edit1: Since the SDA line is tied low the problem probably comes from the master. My guess is that the slave waits for the rest of the clock pulses that never come.

I'm not using the Wire library. I wrote my own implementation based on the AMmega328P datasheet.

void TWIInit() {
  TWSR = 0x00;
  TWBR = 0x48; // SCL = 100khz
  TWCR = (1 << TWEN);
}

void TWIStart() {
  TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
  while ((TWCR & (1 << TWINT)) == 0);
}

void TWIStop() {
  TWCR = (1 << TWINT) | (1 << TWSTO) | (1 << TWEN);
  while (TWCR & (1 << TWSTO));
}

void TWIWrite(uint8_t data) {
  TWDR = uint8_data;
  TWCR = (1 << TWINT) | (1 << TWEN);
  while ((TWCR & (1 << TWINT)) == 0);
}
unsigned int TWIReadACK() {
  TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWEA);
  while ((TWCR & (1 << TWINT)) == 0);
  return TWDR;
}

unsigned int TWIReadNACK() {
  TWCR = (1 << TWINT) | (1 << TWEN);
  while ((TWCR & (1 << TWINT)) == 0);
  return TWDR;
}

unsigned int TWIGetStatus() {
  unsigned int statusOfRegister;
  statusOfRegister = TWSR & 0xF8;
  return statusOfRegister;
}

int TWISendBytes(uint8_t slaveAddr, uint8_t regAddr, uint8_t buf[], int numbBytes) {
  TWIStart();
  if (TWIGetStatus() != 0x08) {
    TWIStop();
    return 1;
  }
  // send address and Write bit
  TWIWrite(slaveAddr & 0xFE);
  if (TWIGetStatus() != 0x18) {
    TWIStop();
    return 1;
  }
  // send the register address
  TWIWrite(regAddr);
  if (TWIGetStatus() != 0x28) {
    TWIStop();
    return 1;
  }
  // send bytes
  for (int i = 0; i < numbBytes; i++) {
    TWIWrite(buf[i]);
    if (TWIGetStatus() != 0x28) {
      TWIStop();
      return 1;
    }
  }
  TWIStop();
  return 0;
}

int TWIGetBytes(uint8_t slaveAddr, uint8_t regAddr, uint8_t buf[], int numbBytes) {
  TWIStart();
  if (TWIGetStatus() != 0x08) {
    TWIStop();
    return 1;
  }
  // send address and Write bit
  TWIWrite(slaveAddr & 0xFE);
  if (TWIGetStatus() != 0x18) {
    TWIStop();
    return 1;
  }
  // send the register address
  TWIWrite(regAddr);
  if (TWIGetStatus() != 0x28) {
    TWIStop();
    return 1;
  }
  // repeated start
  TWIStart();
  if (TWIGetStatus() != 0x10) {
    TWIStop();
    return 1;
  }
  // send address and Read bit
  TWIWrite(slaveAddr | 0x01);
  if (TWIGetStatus() != 0x40) {
    TWIStop();
    return 1;
  }
  // get bytes
  for (int i = 0; i < numbBytes; i++) {
    if (i == (numbBytes - 1)) {
      buf[i] = TWIReadNACK();
      if (TWIGetStatus() != 0x58) {
        TWIStop();
        return 1;
      }
    } else {
      buf[i] = TWIReadACK();
      if (TWIGetStatus() != 0x50) {
        TWIStop();
        return 1;
      }
    }
  }
  TWIStop();
  return 0;
}

Edit2: The SDA line, and SCL, is held high not low as I first incorrectly assumed (I probably did something wrong when I measured it and thought it was low but anyway.) The problem was that the resistors I was using as pull-up resistors were in fact 1k not 2k. I changed them for 2k resistors and the problem disappeared.


texts: listener for Plotter library doesn't work

texts:
I try to use Plotter to plot some data from my Adafruit Circuitplayground board, but the listener is kept showing "Scanning serial ports..." and not displaying any plot (as shown below in the picture).

I have java 1.8.0_271 installed (in order to run listener) and I put the listener folder under the same directory as the Arduino code file (though I'm not sure if there's a requirement of where to put the listener folder). Arduino is the latest version. Code is copied from the sample code of the Plotter library


texts:
Fair warning: I'm a newbie when it comes to Arduino, so if I'm not too great at describing things, let me know so I can learn!

I have recently built a fairly accurate laser timer to time sprinters through a section of a soccer pitch, giving a nice reading of their average speed through the zone.

The limitation is that we would love to be able to see their speed as a progressive measurement throughout the sprint.

My problem? I have NO idea where to start. Google has so far come up empty...

All I have is the following link, Best of the 2015 NHL All-Star Skills Competition, illustrating the sort of thing we would like to accomplish. The bit in question starts at around 0:35 when they are talking about sensors in the players' jerseys.

Any one able to point me in the right direction?


texts: Arduino: Record value of the encoder only once at the instant the PS2 joystick reads 128 (when at rest)

texts:
I'm working on a project where I need my arduino to detect the value of encoder at the instant the reading of the joystick change to 128.  When the joystick is at rest, the reading is 128 which also means, my robot will hold its position/brake. Values above or below 128 correspond to the motor moving forward or backward.

I actually want to record the encoder value exactly at the first instant my arduino reads 128, so that I can apply PID position control so that my robot can brake or hold its position against gravity. The first instant when the joystick reads 128, that is the encoder value that I'd like to set as the Setpoint.

Here's some explanations for implementing PID in Arduino.
http://playground.arduino.cc/Code/PIDLibraryConstructor

For instance the joystick readings go from 140, 137, 131, [128], 128, 128, 133, 139, 131, [128], 128 and at the same time, the encoder gives out corresponding values. I need the encoder values at the Joystick value of 128 in the square bracket, [] in the example above.

If I use the code below, it will just run the statements in {} whenever it sees 128, which is not what I want. FYI, the motor sometimes tend to backdrive, and this gives different encoder value also at 128. What I only need is the first encoder value at the first reading of 128 whenever I encounter it.

void loop()
{

  int pwmSpeed;

  int Y_axis = ps2.readButton(PS2_JOYSTICK_LEFT_Y_AXIS);

  Input = encoder0Pos;

  if (Y_axis == 128)
  {

    Setpoint = encoder0Pos;
    myPID.Compute();
    analogWrite(pwm, Output);

  }

  else if (Y_axis > 128)
  {
    pwmSpeed = Y_axis;
    digitalWrite(dir,HIGH);           // set DIR pin HIGH or LOW
    analogWrite(pwm, pwmSpeed);            //analogWrite(pin, value)
  }
  else
  {
    pwmSpeed = abs(Y_axis-255);
    digitalWrite(dir, LOW);
    analogWrite(pwm, pwmSpeed);

  }

}

Thanks.

//New edited code is shown below:

What do you think of the code? Did I do it correctly? I will test it once I get back to the lab.

If 128 is detected, encoder value is stored in Setpoint and then Pid.compute() is executed for as long as 128 is detected. For this duration, Pid.compute() will compute the error = Setpoint - Input and use Pid formula to calculate the Output that can be found in the analogWrite(pwm, Output). Motor will work to maintain its position at Setpoint.

However if other than 128 is encountered, it will just execute the 'else if' and 'else' statement to move the robot forward or backward.

global g_detect128 = false;

void setup()
    {
//any code here
    }

void loop()
{

  int pwmSpeed;
  int Y_axis = ps2.readButton(PS2_JOYSTICK_LEFT_Y_AXIS);

  Input = encoder0Pos;

 if (!g_detect128 && Y_axis == 128)
    {
    Setpoint = encoder0Pos;
    g_detect128 = true;
    }

  if (Y_axis == 128)
  {

    myPID.Compute();
    analogWrite(pwm, Output);

  }

  else if (Y_axis > 128)
  {
    pwmSpeed = Y_axis;
    digitalWrite(dir,HIGH);           // set DIR pin HIGH or LOW
    analogWrite(pwm, pwmSpeed);            //analogWrite(pin, value)
  }
  else
  {
    pwmSpeed = abs(Y_axis-255);
    digitalWrite(dir, LOW);
    analogWrite(pwm, pwmSpeed);

  }

 if(Y_axis != 128)
    {
    g_detect128 = false;
    }

}


texts: What is the difference between serial begin() and wire.setClock() for I2C communication?

texts:
I am a new Arduino IDE user and have a simple question below
For I2C transmission speed setting, there are serial begin() and wire.setClock(). Some sample codes just use Serial.begin() without Wire.seClock(), some use both as shown below. What is the real differences between them? When to use just serial and when to use both of them? Thanks.
void setup() {
  Serial.begin(9600);          // start serial communication at 9600bps

  Wire.begin();                // join i2c bus (address optional for master)

  Wire.setClock(400000); //Increase  I2C clock rate to 400 kHz
}


texts:
I'm having trouble getting my NodeMCU connected to 4 x 4 Digit 7 Segment Displays.
So far I've been able to connect 2 & get them to display things from the demo repository.
However, after trying all possible combinations of different pins & looking up the pinout reference I have no idea why I can't get them to work.
Any help would be greatly appreciated.
I'm working with:

ESP8266 NodeMCU ESP-12E (CP2102)

4 Digit 7 Segment Display (TM1637)

As suggested @romkey:
#include <Arduino.h>
#include <TM1637Display.h>

// Module connection pins (Digital Pins)

#define CLK_1 D2
#define DIO_1 D3

#define CLK_2 D5
#define DIO_2 D6

#define CLK_3 13
#define DIO_3 15

// The amount of time (in milliseconds) between tests
#define TEST_DELAY   500

TM1637Display display1(CLK_1, DIO_1);
TM1637Display display2(CLK_2, DIO_2);
TM1637Display display3(CLK_3, DIO_3);

void setup()
{
}

void loop()
{
  int k;
  uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
  uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
  display1.setBrightness(0x0f);
  display2.setBrightness(0x0f);
  display3.setBrightness(0x0f);

  // Brightness Test
  for(k = 0; k < 4; k++)
    data[k] = 0xff;
  for(k = 0; k < 7; k++) {
    display1.setBrightness(k);
    display1.setSegments(data);
    display2.setBrightness(k);
    display2.setSegments(data);
    display3.setBrightness(k);
    display3.setSegments(data);
    delay(TEST_DELAY);
  }
  while(1);
}

I've tried addressing the CLK_3 & DIO_3 pins as "Dx" but that didn't work as well.
Repos used:

https://github.com/avishorp/TM1637


texts: DC Motor doesn't turn and a beep sound is made, also there is a burning smell

texts:
I was trying to drive a single dc motor with L293D Shield and Arduino Uno

#include <AFMotor.h>
#include <SoftwareSerial.h>

AF_DCMotor motorLeft(3);
AF_DCMotor motorRight(2);

unsigned char opMode = 0;

void setup()
{

}

void loop()
{
motorLeft.setSpeed(30);
motorLeft.run(FORWARD);
delay(5000);
motorLeft.setSpeed(0);
motorLeft.run(RELEASE);
delay(5000);
}

When I turned the power on, a beep sound was made continously. As I was trying to figure out where the sound comes from, I smelled something burning and turned the power off.

I am giving 6V (Four 1.5V  batteries in series) as external power. Burning smell doesn't come from batteries, that's for sure.

The smell comes from arduino or shield or both. But I think it is the the left LM293D driver.

What did I do wrong? Any idea?


texts:
Before committing to learning about the ESP32 and how to program it, I would like to know if the ESP can be programme the same way for production as it can on évaluation boards (with the Arduino IDE).

Since it obviusly much easier than most for microcontrollers, I was wondering if a product is eventually mass produced, if the code used to program the evaluation board (such as this one https://makeradvisor.com/tools/esp32-dev-board-wi-fi-bluetooth/) could be used on the final product.


texts: Which is a better? GPRS SIM800L or GPRS SIM900?

texts:
I will implementate the GPRS technologity in my Arduino project, but before buy the module, I want to know which is a better. If GPRS SIM800L or GPRS SIM900? My needs are send JSON array through POST request.

Thanks and best regards.


texts:
I've searched high and low for something to get me on the right track, it's making me think it might not be possible.

Basically, I want to create a cheap SSD using Arduino (or another microcontroller if it is too weak). I know I would have to implement the SATA protocol on the device and an OS driver for the disk drive. Assuming I could jump those two hurdles, what else would bar me from implementing a rudimentary SSD? I'm not even talking about full production quality, just a SATA wire coming from a mother board plugged into a socket on a breadboard. Do I need flash storage or would I need another kind of chip to handle the data needs?


texts:
I may have been working with my Arduino UNO board improperly,
because now it fails to upload sketches (says some programmer is not responding)
and when I press the cute little restart button, the green LED doesn't do its blink anymore. I am aware what that means, but what I really wonder is how should I properly care the board. I probably will have no other chances to buy more arduinos so this information follows to be of a great importance.

As an example I would give, is touching the arduino board with bare hands risky, how much shock-tolerant it is, what if I mistake some pins, are there pins that cannot be mistaken, what will happen if I declare a pin as an output, but use it for input and the contrary, is loading a PWM program onto TFT touch screen shield unhealthy and so forth and briefly - how should I properly care the arduino board.


texts: Using NodeMCU D8 (GPIO15), D4 (GPIO2) and D3 (GPIO0) pins

texts:
I am using a NodeMCU board and have already used 6 digital pins as output for interfacing with the LCD. I intend to use 2 more digital pins, one as input and other as output for interfacing an ultrasonic sensor.

D8, D4 and D3 are the only digital pins remaining. I understand that D8 (GPIO15), D4 (GPIO2) and D3 (GPIO0) pins of the NodeMCU  have special boot-controlling uses. So how can I use those pins as generic digital pins. Any help is appreciated.


texts:
I have 2 questions.

Why we have to put our functions before void loop and void setup into VScode+platformio?
I switched from arduino IDE to VScode+platformio today, when I upload the sketch with platformio into my esp-12, it doesn't work. (It works with arduino IDE)

I have this Warning: src\main.cpp:46:24: warning: large integer implicitly truncated to unsigned type [-Woverflow]
 const byte menuColor = 0XF206;

[EDIT]The problem comes from these lines:

attachInterrupt(digitalPinToInterrupt(enA), enAin, RISING);
attachInterrupt(digitalPinToInterrupt(enB), enBin, RISING);
attachInterrupt(digitalPinToInterrupt(enBtn), enBtnIn, FALLING);


texts: Digital input on one pin is copied to other pins

texts:
I am working on a phase detection project in which i am trying to find the order in which the incoming signal comes. I converted the 240v 50hz Ac signal to a 7v 50hz square pulse. when i connect one(7v 50hz) of the three lines to a digital pin on arduino it is properly detecting, but the problem is if i check the unconnected pins via oscilloscope i am getting the same signal which i connected as input, so when i connect another line to any other pin the two signals are getting added.

(Image 1)this is what i see in the DSO when i connect one line to the arduino pin and observe other pins
.(Image 2)this is what i get after i give another line as input to arduino and observe the pins.
i tried with 2 to 3 boards but i still get the same problem.

simulate this circuit – Schematic created using CircuitLab

this is the schematic i used for converting the sine wave into square wave, i used 4n33 optocoupler for this purpose.


texts:
I'm following this tutorial to generate square waves using the timers of the attiny85, but I'm afraid this could mess with something else in the chip.
This is the relevant snippet:
// Set up Timer/Counter0 for 20kHz interrupt to output samples.
TCCR0A = 3<<WGM00;             // Fast PWM
TCCR0B = 1<<WGM02 | 2<<CS00;   // 1/8 prescale
TIMSK = 1<<OCIE0A;             // Enable compare match, disable overflow
OCR0A = 49;                    // Divide by 400

I understand that this might affect delay(), but as I'm using watchdog timer to send the attiny to sleep, I think this in this case it should not affect this specific function.
Are there another negative consequences of modifying this timer?


texts: Host a webserver on esp32d that has a hyperlink that triggers an ardiuno song through a buzzer

texts:
I would like to use my ESP32D to create a wireless access point and host an html page that has a hyperlink and a few other things on it that triggers an arduino song (rickroll), and plays it through a buzzer.
I just need to know how to host the webserver and make the trigger hyperlink work, right now the html is set to send "trigger" whenever the link is pressed.
html file https://pastebin.com/sGmPPVYG
(Arduino-song)https://github.com/robsoncouto/arduino-songs/blob/master/nevergonnagiveyouup/nevergonnagiveyouup.ino


texts: What difference makes resistance of thermistors?

texts:
Following this thermistor tutorial i used 1k thermistors (and resistors) instead of 100k as in video.

What difference does it make?
What about 10k thermistors?
Is it good idea to use 1k/10k/100k potentiometer instead of resistors to tune up readings?


texts: is there any archives of melody tones for buzzer used in arduino?

texts:
I am using buzzer in my arduino and I read some articles about using array of tones(notes in music) with different frequencies to play play pleasant melodies.however, I do not find any site and archives for tones used in industrial, such as Start,Stop,warning,danger,next level,.... is there any site that collects these things and if not how can I create my own array of tones?

this is notes I have

#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978
#define REST      0

// DURATION OF THE NOTES
#define BPM 480      //you can change this value changing all the others
#define H 2*Q //half 2/4
#define Q 6000U/BPM //quarter 1/4
#define E Q/2   //eighth 1/8
#define S Q/4 // sixteenth 1/16
#define W 4*Q // whole 4/4


texts: Parse an element that consists of an array using ArduinoJson

texts:
I want to parse an json element that consists of an "array".
In this case
solar->solardata->calculatedconditions->band[0-7]
How can i do this?

My attempt was:

String data = root["solar"]["solardata"]["calculatedconditions"]["band"][0]["#text"];

But it returns NIL

Plattform: ESP8266

Library: ArduinoJson

{
   "solar":{
      "solardata":{
         "source":{
            "@url":"http://www.hamqsl.com/solar.html",
            "#text":"N0NBH"
         },
         "updated":"11 Jun 2017 2032 GMT",
         "solarflux":"75",
         "aindex":"4",
         "kindex":"5",
         "kindexnt":"No Report",
         "xray":"A6.8",
         "sunspots":"0",
         "heliumline":"107.7",
         "protonflux":"1.40e-01",
         "electonflux":"9.37e+01",
         "aurora":"2",
         "normalization":"1.99",
         "latdegree":"66.5",
         "solarwind":"416.2",
         "magneticfield":"-2.4",
         "calculatedconditions":{
            "band":[
               {
                  "@name":"80m-40m",
                  "@time":"day",
                  "#text":"Poor"
               },
               {
                  "@name":"30m-20m",
                  "@time":"day",
                  "#text":"Poor"
               },
               {
                  "@name":"17m-15m",
                  "@time":"day",
                  "#text":"Poor"
               },
               {
                  "@name":"12m-10m",
                  "@time":"day",
                  "#text":"Poor"
               },
               {
                  "@name":"80m-40m",
                  "@time":"night",
                  "#text":"Poor"
               },
               {
                  "@name":"30m-20m",
                  "@time":"night",
                  "#text":"Poor"
               },
               {
                  "@name":"17m-15m",
                  "@time":"night",
                  "#text":"Poor"
               },
               {
                  "@name":"12m-10m",
                  "@time":"night",
                  "#text":"Poor"
               }
            ]
         },
         "calculatedvhfconditions":{
            "phenomenon":[
               {
                  "@name":"vhf-aurora",
                  "@location":"northern_hemi",
                  "#text":"Band Closed"
               },
               {
                  "@name":"E-Skip",
                  "@location":"europe",
                  "#text":"144MHz ES"
               },
               {
                  "@name":"E-Skip",
                  "@location":"north_america",
                  "#text":"Band Closed"
               },
               {
                  "@name":"E-Skip",
                  "@location":"europe_6m",
                  "#text":"50MHz ES"
               },
               {
                  "@name":"E-Skip",
                  "@location":"europe_4m",
                  "#text":"70MHz ES"
               }
            ]
         },
         "geomagfield":"MIN STRM",
         "signalnoise":"S4-S6",
         "fof2":"NoRpt",
         "muffactor":"NoRpt",
         "muf":"NoRpt"
      }
   }
}


texts: Addresible led delay for 24 hours with arduino uno

texts:
Im working on a project with my addresible led strip and arduino uno
I need 3 leds on the strip to light for 24 hours and then the next 3 leds on the strip should light up for 24 hours and so on.
Can somone help me with the code


texts: EEPROM.read data not comparing with DHT11 sensor value - Arduino temp controller

texts:
I'm using a DHT11 to read temperature to control a relay that will control a fan. When 'A' is pressed it allows the user to update the temp value that the relay will go HIGH at. The value is being stored and read to and from the EEPROM but they are not being compared properly in the if statement. Please help!

#include <EEPROM.h>
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <dht11.h>
dht11 DHT;

char temperature[2];
char initial_temperature[2];
char new_temperature[2];
char key_pressed=0;

const int relay = 8;
const int dht11_data = 6;
int temp=0;
int relayState = LOW;
int i=0;
int j=0;
int init_pass = 0;

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the symbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {38, 40, 42, 44};
byte colPins[COLS] = {46, 48, 50, 52};

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

 //initialize an instance of class NewKeypad
 Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

 void setup() {
 Serial.begin(9600);
 pinMode(relay, OUTPUT);
 digitalWrite(relay, relayState);
 lcd.begin(16,2);
 lcd.print("  Welcome to ");
 lcd.setCursor(0,1);
 lcd.print("     Test 2");
 delay(2000);
 lcd.clear();

   }

void loop() {

DHT.read(dht11_data);
temp=DHT.temperature;

lcd.clear();
lcd.setCursor(5,0) ;
lcd.print("Temp");            //display"Temp="
lcd.setCursor(5,1);
lcd.print(temp);
lcd.write(0xDF);              //Display custom characters '°'
lcd.print("C");

delay(200);
initialtemperature();

       // here is the problem - comparing temp>=init_pass
 // 'temp' will not compare with value of 'init_pass'
 // like it does with a number value in it's place.

for(int j=0;j<2;j++){
init_pass = (initial_temperature[j] - '0');

if (temp >= (init_pass)){

 if(init_pass==2)
   relayState = HIGH;
   digitalWrite(relay,  relayState);

   Serial.print(init_pass);
  }
  }

 key_pressed = customKeypad.getKey();
 if(key_pressed=='A')
 change();
}

void change(){
  j=0;
int i=0;
Serial.begin(9600);
lcd.clear();
lcd.print("FanOn Temp=");
lcd.print(initial_temperature);
// Serial.print(initial_temperature);
lcd.write(0xDF);
lcd.write("C");
lcd.setCursor(0,1);
lcd.print("New Temp=");
delay(200);
while(i<2)

{

char pressed=customKeypad.getKey();
if(pressed){
  new_temperature[i++]=pressed;
  lcd.print(pressed);
  EEPROM.write(j,pressed);
  j++;
}

pressed=0;

}
if(i==2){
lcd.write(0xDF);
lcd.write("C");
delay(1000);
lcd.clear();
lcd.print("Saved");
delay(1000);
  }
  }

 void initialtemperature(){

for (int j = 0; j < 2; j++)
initial_temperature[j] = EEPROM.read(j);

}


texts: Problems when attaching a second ultrasound sensor (HC SR04)

texts:
I am working on an obstacle avoiding robot. It uses an ultrasound sensor to avoid obstacles, but currently has trouble avoiding objects that are diagonal to it. Thus, i want to add a second ultrasound sensor, and alternate their readings. I am testing the code, which should look right and then leftn and return the distances. The code worked for just one ultrasound.  and it is a follows:

#include <NewPing.h>
#include <Servo.h>

#define trig_pin1 A1 //analog input 1
#define echo_pin1 A2 //analog input 2
#define trig_pin2 A3 //analog input 1
#define echo_pin2 A4 //analog input 2
int distance1 = 100;
int distance2 = 100;

#define maximum_distance 200 //sensor function
Servo servo1; //our servo name
Servo servo2;
NewPing sonar1(trig_pin1, echo_pin1, maximum_distance);
NewPing sonar2(trig_pin2, echo_pin2, maximum_distance);
void setup() {
  // put your setup code here, to run once:
  servo1.attach(11); //our servo pin
  servo1.write(90);
  servo2.attach(6); //our servo pin
  servo2.write(90);

  distance1 = readPing1();
  distance2 = readPing2();
  delay(100);
  distance1 = readPing1();
  distance2 = readPing2();
  delay(100);
  distance1 = readPing1();
  distance2 = readPing2();
  delay(100);
  distance1 = readPing1();
  distance2 = readPing2();
  delay(100);
}

void loop() {
    int distanceRight = 0;
  int distanceLeft = 0;

        distanceRight = lookRight();
    delay(300);
    distanceLeft = lookLeft();
    delay(300);
  }
}

int readPing1(){
  delay(10);
  int cm = sonar1.ping_cm();
  if (cm==0){
    cm=250;
  }
  return cm;
}

int lookRight(){
  servo1.write(50);
  delay(500);
  int distance1 = readPing1();
  delay(100);
  servo1.write(115);
  return distance1;
}

int readPing2(){
  delay(10);
  int cm = sonar2.ping_cm();
  if (cm==0){
    cm=250;
  }
  return cm;
  }
int lookLeft(){
  servo2.write(170);
  delay(500);
  int distance2 = readPing2();
  delay(100);
  servo2.write(115);
  return distance2;
  delay(100);
}

I get the following error:
'readPing1' was not declared in this scope

and I get the same error for the readPing2 function. Why could this be?


texts: How to power an Arduino Uno with 3 1.5V batteries?

texts:
I have an Arduino Uno (a SainSmart model, actually). I intend to power it with three 1.5V batteries. I measured them and they yield 4.67V in total. The Arduino requires 5V.
The question is, if the arduino will work this way.
I'm not powering complicated microcontroller components here. These components are used:

A buzzer
An LED
A unit of 4 seven segment displays
A couple of buttons as input elements

If the volume or brightness of these components is slightly decreased, it doesn't matter at all. But I would like to know if it will work in the first place.
And also...
Where exactly do I plug the power source in? The power jack, the USB jack, pins, somewhere else?

The schematic looks like this, just to illustrate it. I'm not a good drawer, but you'll get the idea...


texts: Why does a Piezo Buzzer not require a PWM digital pin (Gallileo Gen2)?

texts:
According to my current (poor) understanding, only the PWM pins (with the ~) among the digital pins (ignoring Analog pins) can be passed to analogWrite().  I understand the servo therefore - since interfaced by a variable voltage signal - must be connected to such a PWM pin.

Why is the humble Piezo Buzzer not bound to this condition?
Why can I connect the buzzer to a digital pin that is not PWM (and so should only be able to output binary LOW, HIGH voltage at some consistent frequency) and still achieve a varying sound by calls to the tone() function?
Surely under the limitations of being digital and non-PWM, the pin could only cause some consistent buzzer frequency?

I'm reading online that the Piezeo Buzzer does indeed require a PWM digital pin, but I can connect it to any digital pin on my Galileo gen2 and have it function seemingly correctly (differing tones produced).

Also, since slightly relevant; what exactly is the difference between a PWM digital pin and an analog pin, in terms of output? They both use PWM, right? Why can't even a PWM digital pin read analog input?


texts:
Despite that I am new to Arduino, I am tasked to invent a serious alarm system and I chose Arduino.
I study electronics, but virtually I am a software programmer and C is my area of expertise.

I ordered the parts I think I will need and the time is immensely pushing me.
The delivery goes slow and it needs to happen before our planned vacation, because
we've been robbed several times so far.
I need to know if I will need another gadgets to deal with a problem I've discovered suddenly.

  >

I plan to stack up these 3 shields

Arducam-F Shield V2 Camera module shield /w OV2640
3.5" TFT LCD Display Touch Screen Module
SIM900 Quad-band GSM/GPRS Shield

From what I've learned the shields 1 and 3 are compatible, as the arducam uses
CS/SD, ICSP, VCC, GND, SDA and SCL
or according to standard pin out table:
I2C_SCL, I2C_SDA, SPI_SCLK, SPI_MISO,
SPI_MOSI, 9, 10, Reset, 5V, GND
and the GPRS shield uses D7 and D0/D1(or D2/D3), 3 I/O ports. For D7.

The arducam however seems to be not stackable and as far as I can not see it is impossible
to make it stackable (Maybe even if I drill holes and solder stackable shield headers)
So it must be the topmost shield.

What about the LCD shield? I also learned that such shields use a lot of pins, so it is possible that there will be no free pins. I also ordered lots of jumper wires of any kind, if that can help.
Maybe I don't need to wire each of the pins in order to make it work or do some extra coding to get it work? I also don't necessarily need the other shields to work while I operate with the screen, so maybe there is a way I can connect/disconnect shields separately with a program or something else I can buy. I have a feeling that this LCD shield will leave no pins for the other shields and I should connect the arducam on another way since it is not stackable.


texts: Comparing custom variable type definitions

texts:
In a library I am using with an OBD adapter, they define a public function to get the state of the OBD connection using some strange (and, in my opinion, useless) custom defined variable type:

// states
typedef enum {
    OBD_DISCONNECTED = 0,
    OBD_CONNECTING = 1,
    OBD_CONNECTED = 2,
    OBD_FAILED = 3
} OBD_STATES;

...

// get connection state
virtual OBD_STATES getState() {
      return m_state;
}

How can I get the state into a variable such as boolean isConnected or int state so it can interact with the rest of my code? I have tried the following with no luck:

boolean isConnected = obd.getState() == OBD_CONNECTED;
if(isConnected) { ... }

int state = (int) obd.getState();
if(state == 2) { ...}


texts: Arduino Uno R3 to Wemos D1 R2 project migration - Pinout problems

texts:
So i've chosen to purchase a Wemos D1 R2 board in order that my old Arduino Uno R3 projects can get some new IoT features. However, even if my code is working in Uno perfectly, i want to test it using D1 before adding features. My problem is that, even if i have found tables showing differences between the 2 boards' pinouts, i cannot understand the correspondence between the pinouts.

So i am giving you the table below. Let's say i want to define echo and trigger pins for a sensor in my code. For example:

#define TRIGGER_PIN 4
#define ECHO_PIN 3

That would be pins D3 and D4 at my Uno. But i cannot understand which those pins would be in Wemos D1 R2. Also, my two boards can be seen below for comparison


texts:
When user used one password after close the servo the password will valid for 15 seconds then it will not work. Other 9 will be same process

Here is code I need just this to set

int locker = 13;
int lockerState = 0;
const int buzzer = 49;
String readString;

#include <Servo.h>
Servo myservo;
int pos = 0;

void setup() {
  Serial.begin(9600);
  pinMode(locker, OUTPUT);
  pinMode(buzzer, OUTPUT);
  myservo.attach(9);
}

void loop() {
  lockerState = digitalRead(locker);
  while (Serial.available()) {
    delay(3);
    char c = Serial.read();
    readString += c;
  }

  if (readString.length() >0) {
    Serial.println(readString);
    if ((readString == "2028") || (readString =="1234") || (readString =="1294") || (readString =="4795") || (readString =="5651") || (readString =="7616") || (readString =="5648") || (readString =="1487") || (readString =="7095") || (readString =="2554"))
    {
      digitalWrite(locker, HIGH);
      for (pos = 0; pos <= 180; pos += 1) {
      myservo.write(pos);
      delay(30);
      }
      delay(5000);
      digitalWrite(locker, LOW);
      /* for (pos = 180; pos >= 1; pos -= 1) {
      myservo.write(pos);
      delay(30);
      } */
      readString="";
    }
      /* else if (readString == "proceed") {
        digitalWrite(locker, HIGH);
        for (pos = 0; pos <= 180; pos += 1) {
        myservo.write(pos);
        delay(30);
        }
      digitalWrite(locker, LOW);
      readString="";
      } */
      if (readString == "decline") {
         digitalWrite(locker, HIGH);
         for (pos = 180; pos >= 0; pos -= 1) {
         myservo.write(pos);
         delay(30);
         }
      digitalWrite(locker, LOW);
      readString="";
      }

    else {
      tone(buzzer, 500);
      delay(1000);
      noTone(buzzer);
      delay(1000);
      readString="";
  }
 }
}


texts: Can i store a SqlLite DB into an (old) ESP32? (not using SD card)

texts:
I would like to know if it is possible to store a (little, basic) SqlLite DataBase (or of any other type) into the (old) ESP32.
I don't want to use an SD card for that (for which I already know it is possible).
Thanks in advance for any hint on this


texts: How do I write the codes in #define in an IR Receiver circuit?

texts:
So I'm trying to turn an ON LED OFF or an OFF LED ON using a TV Remote. In the #define line, I write the hex code received from pressing the designated button on the TV remote. However, during compilation, an error saying unable to find numeric literal operator 'operator""DE74847' appears. I've scoured the web and can't come up with a solution.

#include <IRremote.h>
#include <IRremoteInt.h>
int ledPin = 13;
int IRPin = 3;

#define code1 0575

IRrecv irrecv(IRPin);
decode_results results;
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();
  pinMode(ledPin, OUTPUT);
}
void loop()
{
  if (irrecv.decode(&results))
  {
  unsigned int value = results.value;
  int ledState  = digitalRead(ledPin);
  switch(value)
  {
    case code1:
    if (ledState = HIGH)
    {
      digitalWrite(ledPin, LOW);
    }
    else
    {
      digitalWrite(ledPin, HIGH);
    }
    break;
  }
  }
  else
  {
    digitalWrite (ledPin, LOW);
  }
   unsigned int value = results.value;
  Serial.println(value);
    irrecv.resume();
}

Here's the code. Please help.


texts:
I am using an ATmega328P with internal clock (8 MHz) with a SIM800L module. The default baud rate of the SIM800L is 115,200 baud and I can't make them talk to each other correctly. Although I was able to make them talk very easily at a baud rate of 9600 baud. But now, with a new SIM800L I can't.

Question:

How to change the default baud rate of a SIM800L?
Is it possible to run an ATmega328P at a baud rate of 115,200 baud?

Thanks in advance!

EDIT:

I know that I can run atmega328p at baud rate of 115200 with different crystal, but is it possible to it using internal crystal.


texts: Arduino - fuse setting problem on ATmega328P-PU

texts:
I am trying to do fuse setting on ATmega328P-PU chips using an avr programmer.

I was successfully able to do fuse setting on 3 ATmega328P-PU chips (which I bought from one of the sites - I forgot). So I bought three more from Amazon.

When I execute avrdude -c usbasp -p m328p on the previous 3 chips, I got this response, and was able to do fuse setting.

  avrdude: warning: cannot set sck period. please check for usbasp firmware update.
  avrdude: AVR device initialized and ready to accept instructions

  Reading | ################################################## | 100% 0.00s

  avrdude: Device signature = 0x1e950f (probably m328p)

  avrdude: safemode: Fuses OK (E:FF, H:D9, L:E2)

  avrdude done.  Thank you.

But when I execute the same command on the 3 chips I recently bought, I am getting this.

avrdude -c usbasp -p m328p

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
     Double check connections and try again, or use -F to override
     this check.

avrdude done.  Thank you.

I triple-checked the wiring and soldering area. They all look fine.

Is this because the 3 chips I recently bought have a bootloader?

The description for the chip that works is here.


texts: Using Piezzo Electric buzzer 10V with an Arduino Lilypad USB

texts:
I bought a 10 V Piezzo electric buzzer and I wonder how to connect it to an Arduino (in my case a Lilypad USB, but the question stands for any Arduino I guess...).
I hadn't realized this was a 10V buzzer, whereas the Arduino will support at most 5V.

I tried a simple layout such as below, with the sample code from a sparksfun tutoral, but that's not working!

So, how can I do it? ... or should I use another buzzer ?

Thanks


texts:
I'm working on a project where I need a high torque stepper motor. The stepper motor being used is rated at 12 - 24 volts and when I used a 12 volt battery supply composed of 8 AA batteries it appeared to work fine.

Because I wanted higher torque I set the pot on the Easy Driver to 0.5 amps which is within what was recommended for the motor, and used a Lithium Ion battery originally being used for a power drill rated at 18V and 1.5Ah.

When I connected the battery to the easy driver the motor got very hot and would shake when I tried to turn it but not turn. Now the motor will not work with the 8 AA batteries either. Heres a link to the motor US Ship OSM 5:1 Planetary Gearbox Nema 8 Stepper Motor Samll Size High Torque.

What did I do wrong and how can I fix it?

P.S. I am using a photon as the micro controller and the motor is being controlled using the Blynk app I eliminated the chance of it having to do with the photon or Blynk App.

I found out that the battery I'm using is the Makita BL1815 and it is really composed of 2 batteries which are both rated at 15C. I am not sure if C-rating adds or stays the same when you are using two batteries. When I measure the Voltage on the test points I get 4.27V and when using a formula to find current for the Easy Driver I get 0.480A.


texts:
I'm trying to connect a 3.3v depth sensor to an Arduino uno. The logic level converter does not seem to send any current over (the sensor does not work and the voltmeter reads nothing). I tested the depth sensor separately, so I know it works, meaning it must be the converter. Why wouldn't it be working?

I've tried two logic level converters so far, but neither seems to work. This is basically how I connected it:

Here's the LLC:

Did I mess something up soldering it or by plugging it in wrong earlier?