texts: Unexpected result with the GSM module A6

texts:
I have a GSM A6 module, like this one.

I'm going to use an Arduino Nano as a bridge to communicate with it, I have an external power source (since I read that this module can consume up to 2A at its maximum consumption) (this power supply shares the GND with the module and the Arduino) and I upload the following code in the Nano:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);

void setup()
{
  //Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);

  //Begin serial communication with Arduino and A6
  mySerial.begin(115200);

  Serial.println("Initializing...");
  delay(1000);

}

void loop()
{
  updateSerial();
}

void updateSerial()
{
  delay(500);
  while (Serial.available())
  {
    mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while(mySerial.available())
  {
    Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
  }
}

I set the baud rate at 115200 of my SoftwareSerial port (connected to 10 and 11 pins on the ArduinoNano) because (even if the module says that it has auto-detect speed hability) doesn't work if I set the speed at 9600 (or any other), and I modified the SoftwareSerial library for expand the buffer from 64k to 512k (trying to solve this problem) following this page instructions (also: NICE WORK in this page!!!).

And it works ... it works relatively well, I mean:
The AT commands to test (according to the datasheet itself) are AT and ATI (in one I recieve "AT /r OK" and the last one give some usefull information like the OS and other things), and they work, only they do not show me the same answer always, I leave screenshots:

As you can see, the answers are not always exact, there is some garbage characters, and I need them to be exact, because my idea is to create a kind of alarm, in which the Arduino (One, Nano or Mega) sends and receives AT commands. I worked with the SIM900 module before and always received the same answer when I sent an AT command.

So... any help?!


texts:
I want to turn on 2 bulbs using 2 MOSFETs. The problem is that they both turn on when it should turn up just one light.

Code:

void setup() {
  pinMode(13, OUTPUT);
  pinMode(7, OUTPUT);
}

void loop() {
  digitalWrite(13,1);
  digitalWrite(13,0);
}

See circuit below:


texts:
I am trying to create an electric meter reading setup for Arduino, and I have been searching for it and almost every posts available is using LDR sensor.

http://www.reuk.co.uk/wordpress/solar/flashing-led-on-electricity-meter/
https://jonarcher.info/2014/03/arduino-based-electricity-monitor/

And since it is using LDR, the system should be kept in a dark area, or that the LDR is taped to the flashing LED so that no other light source will interfere the sensor.

But I wanted to have a different setup, and what I am thinking is:

inside the electric meter, tap into the blinking LED
From the LED, connect it to an LLC (https://www.sparkfun.com/products/12009)
From the LLC, connect it to the Arduino
Arduino will sense/detect the pulse of the LED.

Is this a possible setup? Will it not fry the Arduino or the LLC? Will Arduino be able to detect the pulse?

If not, are there any other options? can I use discrete components instead? (I will be the one creating the circuit connection for the LED and Arduino, using resistor, diodes, etc.)


texts: Arduino hangs on second GSM message (was GSM based led matrix display)

texts:
Friends, my team and I are working on a gsm based wireless display as a part of our project. We are using Arduino UNO as the microcontroller which is interfaced with a sim900 module. Upon arrival of a new sms in the gsm module, its contents will be passed on to the dot matrix led display through SoftwareSerial. We almost got the code working but the problem we now encounter is the reception of new sms. The code works fine for the first sms but to display the next new sms, we had to manually reset the Arduino every time. Can you guys help me? This is the code:

#include <SoftwareSerial.h>
#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
#include "SystemFont5x7.h"
#include "Arial_black_16.h"

#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

int temp=0,i=0,x=0,k=0;
char str[160],msg[160];
void ScanDMD()
{
  dmd.scanDisplayBySPI();
}

SoftwareSerial SIM900(0, 1);

void setup()
{

   Timer1.initialize( 5000 );
   Timer1.attachInterrupt( ScanDMD );

   dmd.clearScreen( true );
   Serial.begin(9600);

   SIM900.begin(9600);
   void SIM900power();
   delay(20000);

     SIM900.print("AT+CMGF=1\r");
  delay(100);
  SIM900.print("AT+CNMI=2,2,0,0,0\r");
  delay(100);
}

  void SIM900power()

{
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(7000);
}

void loop(){
for(unsigned int t=0;t<60000;t++){
  void serialEvent();
  if(temp==1)
  {
    x=0,k=0,temp=0;
    while(x<i)
    {
      while(str=='#')

      {
        x++;
        while(str!='*')

        {
          msg[k++]=str[x++];
        }
      }
      x++;
    }
   }
  }
     const char* dchars;
      dchars=msg;
     dmd.clearScreen( true );
   dmd.selectFont(Arial_Black_16);

  for(unsigned int i=0;i<=300;i++){
   dmd.drawMarquee(dchars,strlen(dchars),(32*DISPLAYS_ACROSS)-1,0);
   long start=millis();
   long timer=start;
   boolean ret=false;
   while(!ret){
     if ((timer+30) < millis()){
       ret=dmd.stepMarquee(-1,0);
       timer=millis();
     }
   }
 }
}

void serialEvent(){
  while(Serial.available())
  {
    char ch=(char)Serial.read();
    str[i++]=ch;
    if(ch == '*')
    {
      temp=1;
    }
  }
}

The DMD library was found on the net.


texts: Please Correct my Delay Code without using delay();

texts:
This is my loop()function:

if(Serial.read() == 't') {
  tarestate = true;
}

while(tarestate == true) {
  timeNowTare = mills();
  if(mills() - timeNowTare >= 3000) {
    Serial.println("Tare");
  }
  tareState = false;
}

Where tareStare is a boolean, timeNowTare is a long.

I need to print on serial:

  Tare

three seconds after I enter "t" into serial.

With everything I have tried to date, the program either stops or tares immediately after entering “t”.

EDIT: Thanks to everyone who responded with answers.
The solution was simply to move the timeNowTare = true; declaration up to the Serial.read() if statement. I also changed the while loop to an if statement because it seemed to make my code run quicker.


texts: Arduino how to get amount of elements in an array?

texts:
Hello  have an array of strings that loads strings from a txt file on an sd card.
The txt file on the SD card can change from time to time(not while the Arduino is running).I want to be able to get the amount of elements in the array after the txt file has been loaded into the array. The txt file has lines of txt in it. Each line in the file is put into a string in the array. I want to be able to get the amount of elements in the array how can I do this?


texts: How to switch on an AC bulb using arduino as well as regular switch?

texts: I'm trying to build a GSM based AC Power ON/OFF switch using Arduino. I've successfully completed the ON/OFF mechanism using SMS with the help of 240v 100amps relay to control the circuit. Apparently I don't want to disturb the regular on/off switch's operation. I want both of them to be operational. When I'm not at home arduino should be the switch control and the regular one should be preferred while at home. I'm actually a noob in this topic, and want your precious help to solve this issue.


texts:
I have two Nano boards, but the first one seems the CH340 chipset was burn. :( ,

Nano v3, CH340 chipset but unable to identify after connect to my Mac using USB
Nano v3, FTDI chipset and in good condition
USB to Serial module, using FTDI chipset

I am trying to upload a sketch via a USB-to-Serial module OR another Nano board (or UNO board v3) to my CH340 Nano Board.

Question:

How to wire them up?
Is it need upload a "Arduino as ISP" first?
step-by-step tutorial or website talking about this ??


texts: ESP8266 and Arduino bidirectional streaming from and to a website

texts:
I was looking for some easy tutorial on bidirectional communication via ESP8266 connected to Arduino UNO. I want to send and receive strings from and to JQuery based website.

However, I couldn't find any answers on this because most of them are about working directly with ESP. It's probably easy thing to setup but I'm totally new in working with network communication ;(

At this moment I know how to set AT for ESP as client and receive messages with pin number to toggle:

AT+RST
AT+CWMODE=1
AT+CIPMUX=1
AT+CWJAP="user","pswd"
AT+CIPSERVER=1,80
AT+CIPSTO=10

And JQuery for buttons (data is their ID) form one of tutorials:

$(".led").click(function(){
    var p = $(this).attr('id');
    $.get("http://192.168.1.14:80/", {pin:p});
});

Problem with this is whenever I send something the ESP gets the value and prints info but then it disconnects after 10 seconds (defined time) and when I hit the button again it reconnects and I can't do more (for example: send another value) during the time when it's connected.

Is it normal behavior? How to make it possible to send many messages when it's still connected to the port without waiting to reconnect? Can I make it in more "streaming" way? And how to make this bidirectional? Any advice on configuring the device will be helpful.


texts:
I have an NodeMCU with an ESP8266 32Mbit, I am trying to flash the AT Firmware as described in  Non-OS AT Instruction Set with NONOS-SDK-3.0 but I dont get any responses. I have the MCU connected by USB and use the Flash Download tools.
The NCU should be used together with an Arduino.

For the AT Commands, I tried it over Putty and with the Andruino IDE with 115200 baud rate.

Best regards,

Bravodelta


texts: Individually addressable LED Strip Hardware Suggestion

texts:
I'm looking for high "Refresh Rate" individually addressable LED strip.  The project I have in mind will need a to rapidly changed the color of each led. The higher the resolution the strip the better. Most everything I find online is fairly low resolution so if anyone has any suggestions it would be greatly appreciated.
Thanks!


texts: Arduino 1.6.4 not showing any /tty/ options in Serial ports

texts:
hej guys,

recently I upgraded to Arduino's 1.6.4 IDE just to find out, that I can't seem to upload anything to my board. More specifically: The 1.6.4 IDE is not giving me the option to select the /tty/ board from the serial port list. I am avid Sublime Text 2 user, so obviously I tried to select the port in Stino and voilá: I was able to upload it to my boards.

Since I wanted to sort out if this is a software or hardware problem, I started to experiment with all my boards:

(all of them official boards, no clones)

2 x Arduino Micro
1 x Arduino Uno r3
1 x Arduino Duemillanove
1 x Arduino Mega 2560 r3
12 x Teensy 3.1
a bunch of different USB cables.

none of these boards were registered by the Arduino 1.6.4 IDE, even after restarting the software and the computer several times. i'd only get this in my port selection:

funny enough, my terminal told me the /tty/ device was there. here with the uno connected:

Dash:~ julianh$    ls /dev/tty.*
/dev/tty.Bluetooth-Incoming-Port
/dev/tty.Bluetooth-Modem
/dev/tty.usbmodemfa131

I also tried to re-install FTDI drivers, with no results.

only when I installed the old (trusty) 1.6.1 version, I was able to upload again.

all of the boards are also working fine. I just used my uno and mega another machine a few days ago for some side projects.

can someone confirm this problem with the new IDE 1.6.4 on OSX Yosemite 10.10.3? or is there any solution available online?

thanks!


texts: How to have multiple digital outputs for the same pin on Arduino Uno and Simulink?

texts:
I'm trying to develop a PID controller with Simulink as shown in the image PID. I'm using a PID controller to control a motor via an Arduino Uno and motor driver.

I have the PID output connected to an if statement.

If u1 is larger than 0 then output 1 for digital output pin 2 and output 0 for digital output pin 4.
If u1 is smaller than 0 then output 0 for digital output pin 2 and output 1 for digital output pin 4.

This changes the direction of the motor so that if the PID overshoots it will change direction. And so on for u1 is smaller than 0.

I also have the PWM signal for the speed of the actuator from 0 being the slowest and 255 as the fastest[]. I forgot to fix the label for it.

I keep getting an error when I try to run it. The error says that I can't run it because of having multiple digital output blocks with the same pin as shown in this image Error in Simulink.

Is there a solution for this?


texts:
So, I've put together my Christmas tree lights - a string of WS2811s driven by my Uno board. They are 12 volt WS2811s, so I have rigged a 12 volt supply to them and just using the Uno for the data channel, powered, initially by the USB port of the PC. So far, so good.

Then I take the whole arrangement to the tree and try to power the Uno from a USB charger - but that's where it all goes wrong! The LEDS start to flash madly, nothing like the pattern that I've programmed.

I've tried various USB chargers and various USB cables to no avail, I've tried powering with 6 volts to the DC in socket - same thing. When I go back to the PC and pick up the Uno power from the USB cable, all is good! I have no idea what can be causing this, please help!


texts: Update class attribute with attachInterrupt

texts:
I want to refactor this code

/*
YF‐ S201 Water Flow Sensor
Water Flow Sensor output processed to read in litres/hour
Adaptation Courtesy: www.hobbytronics.co.uk
*/
volatile int flow_frequency; // Measures flow sensor pulses
unsigned int l_hour; // Calculated litres/hour
unsigned char flowsensor = 2; // Sensor Input
unsigned long currentTime;
unsigned long cloopTime;
void flow () // Interrupt function
{
   flow_frequency++;
}
void setup()
{
   pinMode(flowsensor, INPUT);
   digitalWrite(flowsensor, HIGH); // Optional Internal Pull-Up
   Serial.begin(9600);
   attachInterrupt(0, flow, RISING); // Setup Interrupt
   sei(); // Enable interrupts
   currentTime = millis();
   cloopTime = currentTime;
}
void loop ()
{
   currentTime = millis();
   // Every second, calculate and print litres/hour
   if(currentTime >= (cloopTime + 1000))
   {
      cloopTime = currentTime; // Updates cloopTime
      // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
      l_hour = (flow_frequency * 60 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
      flow_frequency = 0; // Reset Counter
      Serial.print(l_hour, DEC); // Print litres/hour
      Serial.println(" L/hour");
   }
}

Originally found here: source

to an Class based solution:

/*
YF‐ S201 Water Flow Sensor
Water Flow Sensor output processed to read in litres/hour
Adaptation Courtesy: www.hobbytronics.co.uk
*/
class FlowSensor {
  volatile int flow_frequency;
  unsigned int l_hour;
  unsigned char pin;
  unsigned long currentTime;
  unsigned long cloopTime;
  public:
    void flow () {
      flow_frequency++;
    };
    void setup() {
      pinMode(pin, INPUT);
      digitalWrite(pin, HIGH); // Optional Internal Pull-Up
      Serial.begin(9600);
      attachInterrupt(digitalPinToInterrupt(pin), flow, RISING); // Setup Interrupt
      sei(); // Enable interrupts
      currentTime = millis();
      cloopTime = currentTime;
    }
    void loop() {
      currentTime = millis();
      // Every second, calculate and print litres/hour
      if(currentTime >= (cloopTime + 1000))
      {
        cloopTime = currentTime; // Updates cloopTime
        // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
        l_hour = (flow_frequency * 60 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
        flow_frequency = 0; // Reset Counter
        Serial.print(l_hour, DEC); // Print litres/hour
        Serial.println(" L/hour");
      }
    }
    FlowSensor() {
      setup();
    };
};
FlowSensor flowsensor_intake;
void setup()
{
   flowsensor_intake = FlowSensor();
}
void loop ()
{
   flowsensor_intake.loop();
}

But i get the following error in the Arduino IDE:

  /tmp/087639235/water_flow/water_flow.ino: In static member function
  'static void FlowSensor::flow()':

  /tmp/087639235/water_flow/water_flow.ino:17:19: error: cannot call
  member function 'void FlowSensor::update_flow()' without object

  update_flow()

  ^

  exit status 1

I understand that flow is not a static function and that i cannot make it static because it is midifying a non static member.

But i cannot think of an alternate solution to this Problem. My goal is to monitor multiple flow sensors by creating an object in the setup() function, and updating them with every loop() call.


texts: 3pin (GND, 12V, tach) 12v FAN control using PWM

texts:
I know there are fans out there that have a dedicated PWM input, but I like to know if I can PWM control a fan that does not have such a dedicated PWM input. So...
If I have a 3 pin 12v fan like the Noctua NF-A20 with connections:

GND
12 V
tach out (RPM measurement)

Can I control its speed by PWM on the 12V supply voltage (using a MOSFET most probably)?
Would the tach out still work?


texts: How to play Midi from the Sparkfun Mp3 Player Shield?

texts: in the video: https://www.youtube.com/watch?v=zc1zbwheyE0 I suspect they may be using the midi playback functionality of the chip (VS1053b) on the Mp3 shield. how do you playback Midi from the mp3 player shield? i found this Mp3 shield real-time midi code: https://gist.github.com/microtherion/2636608/revisions but cant make sense of how to use it. Can you breakdown, explain, or know of any outher sources that can help in playback of midi with Sprakfun Mp3 shield. how was the project in the video able to do this ?


texts:
As an off-Topic to my main question, regarding Robodyn's Uno+Wifi - it seems that Wifi does not work ( fail to connect and fail find any network ).
Juraj advised to use External Antenna ( did not work ) and try to make an RF calibration as shown on espressif's site. Which I fail to understand how it is done.
a) Can anyone help with RF Calibration ?
b) Might it be another reason for that ?
Guy
EDIT_1
Just to be clear, a sלetch was uploaded and executed successfully to the ESP8266 module (Basic WiFi connect and network scan ).
Edit_2


texts: How to measure voltage with Arduino analog input

texts:
I'm totally new to Arduino and to electrodynamics in general.

I'm wondering what happens if I connect my digital pin to an analog input on Arduino, and make digitalWrite and analogRead on the according pins. Here are the options I can think about:

Just connect them directly - it is not a short circuit, is it?
Connect a resistor in between - the voltage should still be 5v, right? Whatever resistor I use?
Make a circuit: digital output -> resistor -> ground, and connect the analog input in parallel (in between the resistor and ground) - Does it make sense? What is the difference with the previous option?

As you see, I'm really confused now. I would highly appreciate if someone could explain in detail what is happening in all the cases, with corresponding values for the current, voltage and resistance.


texts:
I bought a GSM module, and I want to connect it with Arduino but I have a problem.

I linked GSM SIM800L with regular LM2596 12 V 2 VA I changed tension to 5 V, So far the GSM is working but if I connect TX_ARDUINO with RX_GSM the module enters in the loop of the restart.

The picture explains the montage.


texts:
there. Well I am have trying to connect my arduino to a water pump (5V DC).

The problem is, I cant wrap my head around how to connect it to a power supply, can I use my old Nokias phone charger as power supply? Its 5v.

This is sort of a pump like I have
https://www.banggood.com/Machifit-JT80SL-DC-3-6V-Water-Pump-120LH-Ultra-quiet-Micro-Horizontal-Submersible-Mini-Water-Pump-p-1348608.html?rmmds=buy&cur_warehouse=CN

Just mine is 5v.

I have red and black wire, what should I connect to my phone charger?

I tried connecting it directly to arduino but it doesnt seem to work.

And if I connect it to my phone charger like that, what do i do with the 2nd wire?

And at the end, main concern is, how do I keep it turned on and off? How do i make a switch so it knows when and when not to work with arduino?


texts: Yesterday i downloaded the new version of the IDE to take advantage of all the new features, but it just won't open. I tried installing it to different paths, different PC's, i deleted the package_index.json and the cache folder, but nothing. It stucks in the opening screen (see image below), any other ideas?


texts: How are errors (not related to syntax) managed in arduino and in the AVR architecture in general?

texts:
I was just curious about how the AVR architecture manages errors that would cause a regular desktop program to crash. I'm talking about logical errors for example math problems that are undefined. Such as division by 0 and getting a square root of a negative number. At first I was expecting that by giving an error to the AVR chip it will just return 0. But I ran this program:

void setup() {
Serial.begin(9600);
}
void loop(){
int x = 0;
int p = 50;
int result;
result = p/x;
Serial.println(result);
result = sqrt(-10);
delay(1000);
Serial.println(result);
delay(10000);
}

and got this output:

4294967295
0

After this I got really confused. Why would the result variable take the maximum value of an unsigned long? Since I declared an int the micro controller must have dedicated 2 bytes of dynamic memory to this variable but apparently it somehow managed to get additional 2 bytes to store the data. Could this mean that the AVR chip can corrupt data in other memory locations while allocating new data for the variable that just was fed a undefined in to it? Okay maybe the AVR chip just sets any mathematical nonsense to 4294967295. But no in the example of getting the square root of -10 we see that the value became 0. Although this is probably a function processed by some library so maybe there is some kind of protection against these errors. Also, I tried to run the program above but with a byte variable for the result instead of int.

void setup() {
Serial.begin(9600);
}
void loop(){
int x = 0;
int p = 50;
int result;
result = p/x;
Serial.println(result);
result = sqrt(-10);
delay(1000);
Serial.println(result);
delay(10000);
}

And the result was the same. So, is there some kind of documentation about error management in AVR since this is important to know while development.

P.S. Everything was run on a real Atmega 328p chip on an arduino nano.


texts:
Greeting to all,
i have a mega2560( NOT AN ADK ), and usb host shield 2.0, and the following
a) 1 pendrive( 8GB) formatted as fat32
b) 1 300GB usb hard drive formatted as fat32
c) 1 1TB usb hard drive also formatted as fat32
i know, there is a limit on fat32 that the maximum
drive/partition size must be 32GB, and i have found
a disk utility that can format such big drive as fat32(
if you want to know what it is, please ask)
after formatting all these drives( a)+b)+c) ), i have
created folders+files on them, no access problem when
using them in linux, mac, win?;
so i have wrote a sketch in arduino and was successful
in create+write to the pendrive, but when i use the
identical sketch to write to the other two drives, the
sketch died at usb init;
all these were using the same+identical arduino+usb
host shield 2.0, and the operation of the hard drive(
one at a time ) was power with external adapter,
after b) and c) failed, again i used the same pendrive,
and wrote successfully;
then i reformatted those two large drives as fat32(this
time both with size 30GB)...again failed at usb  init;
any advice/suggestion would be greatly appreciated ,
thanks for reading and STAY HEALTHY !!!


texts:
I have two PCBs with ATmega328 that will communicate through I2C protocol. The master will also provide power for the slave, which is located at a relatively short distance (30-40cm or 12-16 inches).

Is it feasible to use the same cable for power (3.3V) and communication?

Thank you.


texts: Powering a DC motor with an external battery

texts:
I'm working on a project where i need to control a 6 volt motor with an Arduino. The motor that I'm using requires 6 volts so I'm using a 9 volt with a voltage divider to get those 6 volts. My problem is that when I use the external power, the motor keeps spinning and ignores the input from the Arduino. If I use a 5 V battery and draw the 5 V from the Arduino, it works fine. I made sure that the voltage divider sends out 6 volts and the current code should have the motor not spinning. Here is the circuit: Motor Schematic.

What could I do to make the motor take the input from the Arduino?

Note: The schematic isn't like my actual circuit. In reality I have 6 V power supply instead of a 9 V and a voltage divider. I also am using a motor that requires 6 volts, while the one in the schematic requires 5 V.


texts:
I just installed the Arduino IDE on Mac and connected the programming port to my Arduino Due. I selected the corresponding board from Tools (though not sure which ATMEL programmer I should choose) I click upload and it gives

In file included from /Users/deepayanbhadra/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/sam.h:198:0,
                 from /Users/deepayanbhadra/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam/chip.h:25,
                 from /Users/deepayanbhadra/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino/Arduino.h:42,
                 from sketch/Blink.ino.cpp:1:
/Users/deepayanbhadra/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/sam3.h:59:37: fatal error: sam3xa/include/sam3xa.h: No such file or directory
   #include "sam3xa/include/sam3xa.h"

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

I'm pretty bumped off as this was my first example. When I connect the USB to the board, the ON is green, the L above and TX below the programming port is yellow. Is this okay?


texts: ESP8266 reseted due to relay / AC plugged

texts:
My Wemos card is reseting for unknown reason. For example, the pump plugged on the relay works fine till 1am and then the pump stop. After a few research I figured out the ESP should reset because all internal parameters are reseted.

My hardware is simple Wemos card + relay + sensors (not here because not connected yet).

My program is quite complex. I can command/configure the wemos via webservice (ex relay on pin 5 with on 5min/off 10min).
https://github.com/TittyPanda/ESP-commander/blob/master/ESP-COMMANDER

OK if no AC device is connected on relay (no reset)
OK if a light is connected on relay
The issue occurs only when the water pump is connected

Maybe it's an electrical/electromagnetical thing because the pump has motor. What do you think ?

Thanks,

EDIT
Power part are done with common wires from power extension cord

AC-DC converter 5 V 1A 1.5A 500mA

Pump 40W 3000L/H 220V 50Hz


texts:
I'm planning on integrating an Arduino Micro in the circuit of a small project of mine (USB gamepad). The whole thing will use USB for power and data transfer (between the board and the computer). Before I move on with prototyping, I need to clear up some questions I have about the Arduino Micro schematic (picture included for reference):

Since I'll be powering off of USB, I won't the 5 and 3.3 V regulators or the 5 V Selector (top-right in picture). Am I correct?
For the USB Micro header, does the schematic refer to any particular header (doesn't seem so to me), or will any generic one work? And what are the six pins on the right side (SH1/S1, SH2/S2, SH3/S3, SH4/S4, SH5/S5, SH6/S6)? What do they do? What are they used for? I found the pins on the left (VBUS, D-, D+, ID, GND) on generic USB Micro headers, but I did not find the pins on the right.
Out of curiosity, what do the asterisks in the schematic mean? You can see them all over; for example, look at the top-right of the MCU.
What do the circle and the smaller circle (with an X through it) towards the bottom-right mean?


texts: Why is this variable giving me always the value of 0?

texts:
I am doing a project and here is the code that I am using, but I do not know why the values of duration and sofia is always 0 so the values of distance and monroy are also 0

const int trigPin = 9;
const int echoPin = 10;

const int t = 8;
const int e = 7;

long duration, sofia;
int distance, monroy;
void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  pinMode(t, OUTPUT);
  pinMode (e, INPUT);
  Serial.begin(9600); // Starts the serial communication
}
void loop() {
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  digitalWrite (t, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  digitalWrite (t, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  digitalWrite (t, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  sofia = pulseIn(e, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2;
  monroy = sofia * 0.034 / 2;
  Serial.print(duration);
  if (distance = 15);
  {
    digitalWrite (3, HIGH);
    delay (5000);
    digitalWrite (3, LOW);
  }

  if ((monroy >= 0) && (monroy <= 5));
  {
    digitalWrite (4, HIGH);
    digitalWrite (5, LOW);
    digitalWrite (6, LOW);
  }
  if ((monroy >= 5.1) && (monroy <= 9));
  {

    digitalWrite (5, HIGH);
    digitalWrite (6, LOW);
  }
  if (monroy >= 9.1);
  {

    digitalWrite (5, LOW);
    digitalWrite (6, HIGH);
  }
}


texts: How do I connect this string of LEDs to my Arduino Uno?

texts: I'm an electronics noob. I have this string of LEDs but don't know how to connect them to my Arduino Uno. As they are wired in parallel, there are two wires / four ends. What do I plug where?


texts:
When I use the Mega 2560 additional serial ports, I realize that it is active low, active high. I know that TTL is active high and the serial port is obviously stated in arduino serial port page.
I also found out that the receive pin flashed (put an LED) when I typed in to the serial monitor. Is this a mistake or problem?


texts: What is the best way/module to talk to an Arduino from far away (WIFI)?

texts:
I am new to Arduino and IoT. I plan to build a product that I will connect to an app and they have to be able to communicate from a very far distance (kilometers).

Bluetooth is not a good option then (because the distance is too far). So would Wifi work? I read something about a module called esp8266 that might be what I am searching for.


texts:
I want to put a 2 seconds delay to temperature reading but the millis() delay is not applying.

#include <OneWire.h>
#include <LiquidCrystal_I2C.h>
#include <DS3231.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

Time t;
LiquidCrystal_I2C lcd(0x27, 16, 2);
DS3231  rtc(SDA, SCL);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

const int OnHour = 23;
const int OnMin = 42;
const int checkTemp = 2000;
const int checkTempinterval = 0;

void setup() {
  Serial.begin(115200);
  pinMode(3, OUTPUT);
  lcd.begin();
  lcd.backlight();
  rtc.begin();
}
void loop() {
  t = rtc.getTime();
  float testTemp;
  testTemp = temperature();
  lcd.setCursor(0,0);
  lcd.print(testTemp);
  lcd.print("   ");
  lcd.print(rtc.getTimeStr());
  lcd.setCursor(0,1);
  lcd.print(rtc.getDOWStr());
  lcd.print("   ");
  lcd.print(rtc.getDateStr());
  if(testTemp >= 28){
    digitalWrite(3,HIGH);
  }else{
    digitalWrite(3,LOW);
  }
//  if(t.hour == OnHour && t.min == OnMin){
//    digitalWrite(3,HIGH);
//  }else{
//    digitalWrite(3,LOW);
//  }
}
float temperature(){
  unsigned long currenttime = millis();
  if(currenttime - checkTempinterval >= checkTemp){
  sensors.requestTemperatures();
  float testTemp = sensors.getTempCByIndex(0);
  currenttime = checkTempinterval;
  return testTemp;
  }
}


texts: Sending sound signal of computer's sound card to arduino

texts: how can i send the signal of sound card to arduino? I want to send sound signal of computer's sound card to Arduino just connect a wire from card to Arduino.. and then i will process it by programming of Arduino after that processing the signal will send via wifi... this is my ideal idea.. how can i do this thing? can i interface Arduino via sound card output pin/jack? can i catch the signal of sound card in Arduino?


texts: Why is my transistor getting very hot when controlling a 12V peristalic pump?

texts:
I have followed this tutorial:

http://www.instructables.com/id/Automatically-water-your-small-indoor-plant-using-/?ALLSTEPS

Every time i try to run my circuit, My transistor gets very hot and breaks.

I have exactly the same parts as the tutorial. I have also tested the circuit with 3.3V Power supply and a diode instead of an engine, this works.

I am super thankfull for any answers.


texts: clkI/O 256 & 1024 (From prescaler) not working with driving PWM on Nano board

texts:
I've been working with PWM in TIMER0 of my nano board.

So, it's working now and I know how to set OCR0A or OCR0B.

Then, I went to play with Clock Select Bits CS02 CS01 CS00 in TCCR0B.

0, 8 and 64 prescaler configurations worked as I also don't see the effect on the LED fade speed.

But the more problem I get is that 256 and 1024 prescaler don't work at all and the LED goes on all the time.

What is the problem?

The code:

void setup() {
    DDRD |= (1<<DDD6);
    TCCR0A |= 0xC1;
    TCCR0B |= 0x00; // this works for 0x01, 0x02, 0x03 only
    }

    void loop() {
    uint8_t i;
    for (i=0;i<256;i++)
    {
      OCR0A = i;
      _delay_ms(1);
    }
    }

regards,


texts:
Using Windows 10 computer:
Downloaded/Installed Ard_IDE 2.0.0 in  Local Disk(C:)/Program Files(x86)/Arduino
 Previous Ard_IDE 1.8.10 saved as  Local Disk(C:)/Program Files(x86)/OLD Arduino
                                                                    //|\\changed name

NOW when Arduino is operated using previous DeskTop, Arduino[icon ] then  Arduino 1.8.10  still Runs
Arduino 2.0.0 is NOT activated.
Please Help.
martymarty


texts: I need help with my LCD. I have a 20x4 LCD and it shows up as 20x2. The LCD address said "// Set the LCD address to 0x27 for a 16 chars and 2 line display". I changed it which says "// Set the LCD address to 0x27 for a 20 chars and 4 line display" and uploaded it, thinking it would show up as 20x4 as it should. But it didn't work:


texts: DS3231 OSF register changing without lost date

texts:
Dears, I have an logger prototype with arduino and ds3231 breadboard. My code check periodically OSF register to check if oscillator is/was stopped, as informed in datasheet. I turn on my logger, setting up date/hour, turn of and after some time, turn it on again to check if it's ok.

After that, the logger stay tuned off for a month. When I turned it on after this time, I note that OSF bit was changed, indicating that oscillator was stopped, but the data/time wasn't lost. I don't found possible process that can change the OSF bit in datasheet and Maxim recommendation. Maybe a negative voltage on VCC that force battery go to bellow threshold can changes the OSF bit (Maxim recommendation and this post).

Then, I test my logger connecting and disconnecting voltage (VCC) and checking the OSF bit, to simulate this possible begative voltage and not have problem with it.

My question is:

why the OSF bit changed, indicating lost of battery and consequently lost of date/time, and not lost date/time in my logger;
what could have happened with my turned off logger to change OSF bit and not lost date;

I'm using Adafruid RTCLib. Follow the simple code to check OSF bit:

#include <Wire.h>
#include <RTClib.h>

RTC_DS3231 rtc;

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

void loop()
{
  if(rtc.lostPower())
  {
     Serial.println("Date lost");
  }

  delay(1000);
}

Thank you!


texts: How to have some code executed at a certain time of day with a DS3231 RTC?

texts:
I recently bought a DS3231 RTC, but I cannot seem to figure out how to get it to work. I have tried all different tutorials and example programs but I keep getting 2165.25.165 165:165:165 as the output.

I am using an Arduino Micro, with the RTC connected as follows:

GND > GND
VCC > 5V
SDA > A4
SCL > A5

Project details:

The project uses a 16x2 LCD to display the time of day, and a countdown to the next occurrence of 06:00. Then at 6 it will allow for a button to be pressed to open a servo and do other things. I got temporary test code to work using millis(), but it is only displaying a 12-hour countdown in seconds, and I would like to replace it with a more reliable RTC.


texts: Generating 200 kHz pulse on Arduino Uno in normal mode

texts:
I need to obtain 200 kHz from Arduino Uno. I am using Timer0. I have configured it to run in normal mode and the Prescaler is set to clk/8 (the clock frequency of Arduino is 16 MHz). TCNT0 is set to 0xFB and the code toggles 2 pins of PORTB as timer overflow flag is set.

Here is my code (I am using Atmel Studio 7):

#include <avr/io.h>

int main(void)
{
   DDRB = 0x03;
   PORTB |= 0x02;
   while (1)
   {
       TCNT0 = 0xFB;
       TCCR0A = 0X00;
       TCCR0B = 0x02;
       while ( (TIFR0 & 0x01) == 0 );
       PORTB ^= 0x03;
       TCCR1A = 0x00;
       TCCR1B = 0x00;
       TIFR0 = 0X01;
  }
}

When I check on the oscilloscope, it shows that the pulse is 166 kHz instead of 200 kHz. Although I can use Fast PWM Mode and use interrupts, I am just curious to know why it doesn't work? Did I make any mistake?


texts: ATMega328 AU bootloader burning issue using Nano

texts:
We are trying to burn bootloader into ATMega328P-AU SMD. We have taken the reference of the link and did the same. We checked wire connections and all looks fine and we tried with two chip with two separate boards and we got same result.

But we tried many times and got the same error as follows,

Could someone help us on this?

    /data/install/arduino-1.8.8/hardware/tools/avr/bin/avrdude -C/data/install/arduino-1.8.8/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/data/install/arduino-1.8.8/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/home/sankar/.avrduderc"

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x15
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x15
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x02

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
         Hardware Version: 4238814
         Firmware Version: 24405360.0
         Topcard         : STK502
         Vtarget         : 1.8 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

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

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

avrdude done.  Thank you.

Error while burning bootloader.


texts: Synchronizing two sensors on uart, make one receiver and one transmitter

texts:
I need to make a transmitter and receiver with each specifically transmitting and receiving a signal. I am using two SRF-02 sensors, one is the designated transmitter, the other the receiver.

My issue is that the receiver is not currently able to pick up the reading, reason being that the receiver has no idea of when the startbyte is incoming or when the stop byte comes.

Can i send the receiver a start byte when i activate the transmitter and send an end byte for when the signal is received?


texts:
I'm designing a custom board with an atmega2560. It will be programmed using ArduinoISP. I want to be sure that i have made no mistakes on my schematic design before I order it. I folloud the schematic for the arduino mega 2560 from the arduino website. For the basic function of uploading a sketch is my design correct?

I can upload the full schematic on pdf if you need it but it just contains some ICs for the final board.

This is the pcb design as asked in the comments!


texts: Where to connect an external power source for an Arduino motor driver shield to?

texts:
I have a BYJ48 stepper motor and an ULN2003A motor driver shield shield.

In many tutorials I read:

  do not to draw current from the 5V on the Arduino rail, but use an
  external power source, since the motor can draw quite some current

Which of these options to they mean by this?

  Connect an external power adapter to the Arduino and connect the
  ULN2003A board to the Vin pin and GND on the Arduino

or

  Connect the motor shield itself to an external power adapter and connect it to the + and - pin on the motor shield

or perhaps both are valid solutions?

The board I use is this one.


texts:
I'm making a POV project and need to count the RPM of the DC Motor.

I purchased a Hall Effect Sensor and it seems to work perfectly at slow speeds, however once the motor speeds up, the sensor doesn't pick up the magnet at all.

The datasheet for the sensor is at:
http://cdn.shopify.com/s/files/1/0045/8932/files/AH180.pdf?100744

This is one of my first projects and I'm not sure what I should be looking for on the datasheet.

The sensor came as part of this product:
http://www.freetronics.com.au/pages/hall-effect-magnetic-and-proximity-sensor-module-quickstart-guide#.VZ0Zs_meDGc

There doesn't seem to be a problem with the code:

int pin = 13;
volatile int state = LOW;
volatile int tcnt = 0;

void setup()
{
  pinMode(pin, OUTPUT);
  attachInterrupt(1, blink, CHANGE);
  Serial.begin(9600);
}

void loop()
{
  digitalWrite(pin, state);
  Serial.println(tcnt);

}

void blink()
{
  tcnt = tcnt + 1;
  state = !state;
}

Thanks!


texts: Multiple functions at the same time with Arduino Uno

texts:
I would like to make a stepper motor run in for loop in time intervals. I also want to stepper motor run when I press the button. Two functions independently. One does not affect the other. I wrote both functions but I have no idea how to make them both work in the same time. I'm using an Arduino Uno.
This is my code:
const int stepPin = 3;
const int dirPin = 4;
const int buttonPin = 2;

void setup() {
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
  pinMode(buttonPin, INPUT);
}
void loop() {

 // One function
   digitalWrite(dirPin,HIGH);

  for(int x = 0; x < 100; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(3000);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(3000);
    }
  delay(30000);
    }

// Second function
  digitalWrite(dirPin,HIGH);
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
  digitalWrite(stepPin,HIGH);
  delayMicroseconds(3000);
  digitalWrite(stepPin,LOW);
  delayMicroseconds(3000);
}

Can anyone help me? :)


texts:
Does the Bluetooth module HC-06 contains a built in antenna similar to HC-05 ?

and if so, then what is the benefit from using antenna?


texts: Unable to control servo with decoupling capacitor and external power supply, but motor shield works

texts:
I'm a hobbyist trying to up my arduino and electronics knowledge.
I can successfully control a hobby servo using an motor driver shield (https://learn.adafruit.com/adafruit-motor-shield/overview) but am running into issues when I try to control it without the shield using standard servo control circuits.

When the servo is connected to the basic, unworking circuit, it generally doesn't move and clicks occasionally, as though underpowered. It works flawlessly with the shield, when powered just through the standard 5V USB connection.

Schematic of circuit that doesn't work:

Schematic of circuit working with shield (shield is approximation from fritzing):

I've tried :

a 470uF or 1000uF decoupling capacitor between ground and +5V. Also tried with no capacitor.
powering the servo and/or arduino from an external power supply.  Grounds are connected correctly.
Different 5V power supplies. (batteries intended for phone charging, 5V from computer, 5V from wall).
Different Arduino Unos.
Different servos.

Code running on Arduino:

#include <Servo.h>

Servo servo;

void setup() {
  servo.attach(10);
}

void loop() {
  servo.write(135);
  delay(500);
  servo.write(45);
  delay(500);
}

I'd like to understand what I'm doing wrong, how to troubleshoot, and/or what the shield is doing that the basic circuit is not.

I'm using Arduino Unos, a hobbytech YM-2765 servo (rated for 4.8-6V), or a 3001HB servo.


texts:
I would like to create a camera dolly for capturing timelapse movies.

i.e. something like this:
http://youtu.be/Qce1f6SKEMU

Whats a reliable way to detect the end of the track and stop the stepper motor moving the camera? In other words how is it possible to get the current position of the camera and stop the motor before the track ends to prevent crashing into the bumpers?


texts:
While working with JSON parsing I noticed that the char type data string is written like this:
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";

Why there are (escapes) " ---" used in the code? Why can't we use the string normally?


texts:
I am wondering can I use this bicks camera switcher with the arduino since it uses a PWM signal.
If i can do I just put it on one of the PWM outputs or do I need to wire I add something to make it work.
**You can find the user manual here under attachments.**https://store.bicks.us/multiview/20-bicks-s-multiview-duo-fpv-camera-switcher.html


texts: Which motor (type) to use for an arduino controlled magnetic stirrer?

texts:
I am in the process of building my own sous vide machine and like to replace the pump typically found in most commercial machines with a magnetic stirrer unit. I figured the easiest way would be to use a motor to spin a permanent magnet (instead of creating a strong rotating magnetic field electrically). I first started experimenting with some 12V DC fans leftover from an old computer. By either lowering the input voltage or via PWM I was able to obtain appropriate rotational speed (don't ask me about exact speeds, I guess around 300rpm or so). With the project maturing I am not sure which motor (type and/or exact model) to use. I hoped some of you might point me in the right direction for the type of motor or even better, could suggest a specific model. I considered stepper motors or continuous  servo motors. My criteria for the motor are:

easy to control rotational speed between 0 and around 500 or so rpm (for ramp up and variation of speed to increase turbulent flow)
ability to rotate both clockwise and counter clockwise
enough torque at all speeds to spin a disk with magnets attached (weight and inertia probably negligible, the to be used alnico magnets create a field strong enough to lift 0,4kg each)
small axial dimensions
reasonably priced and long lasting
quiet

The following picture shows a commercial magnetic stirrer found in your average laboratory. The blurry white object in the glass beaker is the the so called stir bar or "fish", a PTFE coated permanent magnet. It spins due to the rotating magnetic field created by the actual device underneath the beaker.


texts: 2G/3G vs 4G/LTE Cell Connectivity for Sensor Prototype?

texts:
Would love any advice on Arduino cell connectivity. From what I understand:

2G (GSM/GPRS) is a dying technology. AT&T is shutting down its 2G network on Jan 1, 2017.
2G (CDMA) will have a longer lifespan than GSM in the U.S., although the options for CDMA modules are much more limited than GSM.
3G has poorer coverage than 2G and is no longer growing.
4G is overkill but is also future-proofed.
4G LTE ^ ditto

I am prototyping sensors that will send GPS/accel/gyro/temp data to a server every 30 seconds or so. They will be in the U.S., operate outside of wifi range, and likely not move very much (roaming isn't a factor).

Am I right in ruling out 2G GSM at this point? From what I've seen, the AT&T 4G LTE IoT Dev Kit looks like a decent option but this is the first time I've worked with IoT devices so any suggestions are welcome (http://cloudconnectkits.org/product/att-cellular-iot-starter-kit).


texts:
I'm beginner here at arduino stuff. i just started learning arduino and i have this small homework where i NEEDED to connect 2 arduino using ethernet shield or module ONLY over a distance of 20 meters.

I don't have my modules yet but i want to atleast study it now while i'm waiting for it. I can't seem to see any tutorials about it nor anyone tried it. How can i do this? i hope you can help me and give some insights, links, etc reference. Thanks :)

EDIT:
I had in mind where these arduino will have their own identity, 1st arduino will be receiving only some data coming from 2nd arduino. The 2nd arduino will have sensors and read them then sends them to 1st arduino. Now, i like my 2nd arduino to have a power source coming from the 1st arduino to save power supply installation and since it'll be like a remote arduino. Thus has anyone has experience applying PoE on arduino?


texts: Good tips for how to connect cables into Mux Shield II?

texts: I just got a Mux Shield 2 and got it working as I expected. Now I started to find out how to actually connect the I/O cables to the board. Doesn't seem to be as simple as I thought. I don't want to solder cables into the board for maintenance reasons. So, does anyone have any good tips on how to do this?


texts: How to set a not plugged in pin to ground or Low

texts:
I have digital pin 7 when set to High it does and when set to low it does not.

The only way I can get consistent High or Low is to use a 2 position 3 pin switch with my pin 7 in the middle and ground on one side and 5v on the other.

Is there a way I can use an simple Open/Close switch and still get the same function?

As of not if I dont "pull" pin 7 to ground I get both open and close randomly.


texts: not able to figure out what is wrong with my nodemcu code

texts:
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>

//Firebase settings
#define FIREBASE_HOST "..........firebaseio.com/"     //cant share
#define FIREBASE_AUTH "..............."               //cant share

//Wi-Fi settings
#define WIFI_SSID "kello"
#define WIFI_PASSWORD "8888"

//Define trigger and echo digital pins
const int trigPin = 4;
const int echoPin = 3;

// The amount of time the ultrassonic wave will be travelling for
long duration = 0;
// Define the distance variable
double distance = 0;

void setup()
{
     Serial.begin(9600);
    // Connect to Wi-Fi
    Serial.print("Wi-Fi...");
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
    Serial.print("Connecting...");
    while (WiFi.status() != WL_CONNECTED)
    {
        Serial.print(".");
        delay(500);
    }
    Serial.println();
    Serial.print("Connected to: ");
    Serial.println(WiFi.localIP());

    Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);

    // Ultrasonic sensor, set echo as Input and trigger as Output
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);

}

void loop()
{

    getDistance();
    // Prints the distance value to the serial monitor
    Serial.print("Distance: ");
    Serial.println(distance);

    delay(500);
}

void getDistance()
{
    // Clear trigPin
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);

    // trigPin HIGH por 10ms
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);

    //Reads echoPin, returns the travel time of the sound wave in ms
    duration = pulseIn(echoPin, HIGH);

    // Calculating the distance, in centimeters, using the formula described in the first section.
    distance = duration * 0.034 / 2;

    // Sends the distance value to Firebase
    Firebase.setFloat("distance", distance);

}

I am a computer graduate so i do not have much knowledge about nodemcu. I saw some documentations about nodemcu. I want to show the data obtained by the ultrasonic distance sensor in the realtime database of firebase. But i am not able to figure out why i am not able to get output of serial.println(distance) in the com5 window even though the code compiles successfully .
This is what i get when running the program

Executable segment sizes:

IROM   : 330560          - code in flash         (default or ICACHE_FLASH_ATTR)

IRAM   : 27760   / 32768 - code in IRAM          (ICACHE_RAM_ATTR, ISRs...)

DATA   : 1408  )         - initialized variables (global, static) in RAM/HEAP

RODATA : 2044  ) / 81920 - constants             (global, static) in RAM/HEAP

BSS    : 25160 )         - zeroed variables      (global, static) in RAM/HEAP

Sketch uses 361772 bytes (34%) of program storage space. Maximum is 1044464 bytes.
Global variables use 28612 bytes (34%) of dynamic memory, leaving 53308 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM5
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: ec:fa:bc:c1:44:d2
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 365920 bytes to 264395...

Writing at 0x00000000... (5 %)
Writing at 0x00004000... (11 %)
Writing at 0x00008000... (17 %)
Writing at 0x0000c000... (23 %)
Writing at 0x00010000... (29 %)
Writing at 0x00014000... (35 %)
Writing at 0x00018000... (41 %)
Writing at 0x0001c000... (47 %)
Writing at 0x00020000... (52 %)
Writing at 0x00024000... (58 %)
Writing at 0x00028000... (64 %)
Writing at 0x0002c000... (70 %)
Writing at 0x00030000... (76 %)
Writing at 0x00034000... (82 %)
Writing at 0x00038000... (88 %)
Writing at 0x0003c000... (94 %)
Writing at 0x00040000... (100 %)
Wrote 365920 bytes (264395 compressed) at 0x00000000 in 23.4 seconds (effective 125.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Is the ultrasonic sensor not getting enough power supply as nodemcu is connected to my laptop?
Please help me out and let me know if more information is required.


texts: Receiving SMS by Arduino GSM Shield and control the LED with the content of this SMS?

texts:
I am using Arduino GSM Shield receiving SMS from an Android app. And the content of this SMS will control a LED. If the content of this SMS is not "off", the LED will be on and the content will be printed in the serial monitor. But if it is "off", the LED will be off immediately. Besides, the LED will keep being on until the "off" message coming. For now, I used the code from the example of the software. But I cannot use the content of this SMS to control the status of LED. With the code below, the LED could not be turned on and the content could not be displayed on the monitor. I think it was because the sketch failed to get the whole content of this SMS. Could anybody tell me how to solve this problem? Thanks.

#include <GSM.h>
GSM gsmAccess;
GSM_SMS sms;
char senderNumber[20];
int led=13;
void setup()
{
  Serial.begin(9600);
  pinMode(led,OUTPUT);
  digitalWrite(led,LOW);
  while (!Serial) {
    ;
  }
  Serial.println("SMS Messages Receiver");
  boolean notConnected = true;
  while(notConnected)
    {
      if(gsmAccess.begin("6442")==GSM_READY)
        notConnected = false;
      else
        {
          Serial.println("Not connected");
          delay(1000);
        }
    }
  Serial.println("GSM initialized");
  Serial.println("Waiting for messages");
}

void loop()
{
  char c;
  int val=0;
  val=digitalRead(led);
  if (val==HIGH){
    digitalWrite(led,HIGH);
  }
  if (sms.available()){
    Serial.println("Message received from:");
    sms.remoteNumber(senderNumber, 20);
    Serial.println(senderNumber);

    if(sms.peek()=='#')
      {
        Serial.println("Discarded SMS");
        sms.flush();
      }
    while(c=sms.read())
      if(c='off'){
        digitalWrite(led,LOW);
      }else{
        digitalWrite(led,HIGH);
        Serial.print(c);
      }
    Serial.println("\nEND OF MESSAGE");
    sms.flush();
    Serial.println("MESSAGE DELETED");
  }
  delay(1000);
}


texts: NRF24L01+ Getting Started Acknowledge Failed

texts:
I have followed numerous guides and tutorials for getting the NRF24L01+ modules working with an Arduino Uno. I have swapped to a genuine Arduino and tried 4 different NRF modules. All without luck.

I am trying to get the most basic example from Simple nRF24L01+ 2.4GHz transceiver demo to work.

Hardware Connections:

Simple TX Test Code:

// SimpleTx - the master or the transmitter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte slaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

char dataToSend[10] = "Message 0";
char txNum = '0';

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleTx Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

//====================

void loop() {
    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
        prevMillis = millis();
    }
}

//====================

void send() {

    bool rslt;
    radio.stopListening();
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(dataToSend);

    if (rslt) {
        Serial.println("  Acknowledge received");
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[8] = txNum;
}

Serial monitor:

Using radio.printDetails( ); returns:

Please let me know what I'm missing.


texts: Arduino uint8_t to String or char- retrieve from usb device

texts:
My code returns uint8_t format when is cast to char and Display on LCD it works fine but I want to get that scanned code for further processing. not only to display on LCD 16x2 , but it returns some strange symbols. Any Idea?

#include <LiquidCrystal.h>
#include <avr/pgmspace.h>
#include <hid.h>
#include <hiduniversal.h>
#include <usbhub.h>
#include <Usb.h>
#include <usbhub.h>
#include <avr/pgmspace.h>
#include <hidboot.h>
#include <SPI.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
USB     Usb;
USBHub     Hub(&Usb);
HIDUniversal Hid(&Usb);
HIDBoot<HID_PROTOCOL_KEYBOARD>    Keyboard(&Usb);

class KbdRptParser : public KeyboardReportParser
{
  void PrintKey(uint8_t mod, uint8_t key);
protected:
  virtual void OnKeyDown  (uint8_t mod, uint8_t key);
  virtual void OnKeyPressed(uint8_t key);
};

void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
{
    uint8_t c = OemToAscii(mod, key);

    if (c)
        OnKeyPressed(c);
}

/* what to do when symbol arrives */
void KbdRptParser::OnKeyPressed(uint8_t key)
{
static uint32_t next_time = 0;      //watchdog
static uint8_t current_cursor = 0;  //tracks current cursor position

    if( millis() > next_time ) {
      lcd.clear();
      current_cursor = 0;
      delay( 5 );  //LCD-specific
      lcd.setCursor( 0,0 );
    }//if( millis() > next_time ...

    next_time = millis() + 200;  //reset watchdog

    if( current_cursor++ == ( DISPLAY_WIDTH + 1 )) {  //switch to second line if cursor outside the screen
      lcd.setCursor( 0,1 );
    }
  char keys=(char) key;
    Serial.println(keys);
// char add =keys.indexOf(5)+keys.indexOf(6)+keys.indexOf(7)+keys.indexOf(8);
    Serial.println(keys);
    lcd.print(keys);
};

KbdRptParser Prs;

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

    if (Usb.Init() == -1) {
        Serial.println("OSC did not start.");
    }

    delay( 200 );

    Hid.SetReportParser(0, (HIDReportParser*)&Prs);
    // set up the LCD's number of columns and rows:
    lcd.begin(DISPLAY_WIDTH, 2);
    lcd.clear();
    lcd.noAutoscroll();
    lcd.print("Scan Your Code");
    delay( 200 );
}

void loop()
{
  Usb.Task();
}


texts: Arduino Mega not recognized on Raspberry Pi 3b+

texts:
I'm developing an interactive LED table for an university assignment that is being controlled by an Arduino Mega2560 which gets the information about which LEDs should be lit in which colour from a Java application that runs on a Raspi 3b+. So far everything is almost finished and the program is running quite smoothly.

The whole time I've been developing the Java application on a PC and it worked just perfect. Now I wanted to move the application to the Pi to have a runnable demo for a meeting with my advisor. Therefore I wanted to check on which USB port the Arduino connects to the Pi so I can setup the corresponding part of the Java code correctly. As I also wanted to set a specific descriptive port name on which the Arduino is always accessible for the Java application I followed this tutorial.

In a previous attempt where I still used 2 Arduino Duemilanove that step worked however when I now try to find the Arduino Mega with dmesg | grep ttyUSB I get no results and ls -l /dev/ttyUSB* only tells me that there is no such path or directory. I also retried that with one of the Arduino Duemilanove in case the USB cable was defective but in that case it returned a valid result.

As the code that I need to run on the Arduino is too extensive for using 2 Arduino Duemilanove (due to the array size to represent the table) I definitely need to run this on the Mega. After many attempts to find a solution I didn't find anything that helps me in my situation as every thread on a similar topic was about a board that wasn't recognized on any machine (whereas my Mega gets recognized on my normal Windows PC). As the Duemilanoves get recognized seamlessly I conduct that it's probably not a problem caused by the Pi (or at least not only the Pi).

I read that using a powered USB hub could be a possible solution. However, as the Arduino itself is powered by a power supply  I suppose that using a powered USB hub would not help much in this case? However I'd be happy if someone proved me wrong in this case and solving the issue was as easy as that.


texts: Can I disable the TX pin by setting its mode to INPUT while still receiving data on the RX pin of a UART?

texts:
I'm using the ATmega328PB in a personal project with MiniCore. My board streams data in on the RX pin from another microcontroller, but my board also has a DIP switch connected to the TX pin, that's used for configuration. My board has already been manufactured, so a hardware solution means a board redesign and extra cost/time.

This DIP switch is connected between TXD (Arduino pin "1") and GND. Upon startup, I read the value of this pin when in mode INPUT_PULLUP. However, when I go to start the Serial, if this switch is in the closed position, it shorts the TXD pin to GND.

Is it possible to disable the TX pin by putting it into INPUT mode while still receiving data on the RX pin?


texts: Serial Output on ESP8266 doesn't work on 2/3 of my boards

texts:
I have 3 NodeMCU 1.0 12E ESP8266 boards.
Issues
Two of them require me to unplug and replug in the boards every time I want to flash code, and nothing appears on the serial output with this simple blink modified sketch I've shown below on those same boards. I don't have any special pin configurations on either of these boards, I simply have the NodeMCU boards connected to the PC through MicroUSB. The other board has no issues with uploading and displaying serial output also with no special pin configurations.
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  Serial.begin(115200);
  pinMode(4, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  Serial.println("ON");
  digitalWrite(4, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  Serial.println("OFF");
  digitalWrite(4, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Interestingly enough, the LED connected to the corresponding PIN behaves correctly, which would indicate flashing the code works fine, but serial output doesn't work on 2 of the boards.
What I've tried

Making sure the baud rate of the serial monitor is 115200.

Tried the sketch with different baud rates.

Made sure the correct board and ports are being recognized.

I have tried using certain pin configurations on some of my boards, (grounding GPIO pin 0, connecting Rx and Tx, etc), but like I said, I don't do this in general when uploading code. Maybe the ESP8266 requires some sort of initialization process that I haven't done?

I can't tell if my other two boards are defective or if I need to take extra steps for the two boards that are acting strange. Has anyone here experienced something like this?
Thanks


texts:
I have a BMP280 and BMP180 pressure sensor and I have both of them connected via I²C to a ESP8266.
For the BMP180, I can get the sea level air pressure when I pass the pressure and altitude like so:
// https://github.com/sparkfun/BMP180_Breakout_Arduino_Library
#include <SFE_BMP180.h>
SFE_BMP180 bmp180;
[...]
Serial.print(bmp180.sealevel(pressure, 800));

Is there a similar thing for the BMP280? Reading pressure and temperature works fine:
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp280;
[...]
double temperature = bmp280.readTemperature();
double pressure = bmp280.readPressure() / 100;


texts: Purpose of extra holes for pins or Arduino clone

texts:
I bought this Arduino clone recently and it has lot of extra holes for pins, but some of them I don't know what they do. There was no instruction manual that came with it. Here's a picture of it, I added a red rectangle around the ones I don't know. (4 pins with X1, SCL/SDA, AREF and blank pin in the bottom)

I thought I could use the pins SCL SDA 5V GND with my I2C LCD Display because the names of the pins are the same on it. Could it work? Usually I use analog pins to connect the display, does that mean that by using it some analog pins will be used indirectly? I didn't try connecting it because I don't want it to break.

What do these pins do?


texts: Arduino Zero to Arduino Zero SPI configuration

texts:
I am in the planning stage of chaning two ATSAMD21 with a Zero or Nano 33 bootloade r in a SPI connection. The rational for this is that i am in need of 30 pin GPIO expansion and using 2 mcp23s17 takes a fair bit amount of space and also slightly bit more expensive. Since the ATSAMD21 has theoretical 37 GPIOs why not use that. having not owned a zero board yet, i would like to know if:

Is it easily doable, just connecting the appropriate pins?

If so, i have read in the Arduino SPI documentation that the zero doesnt have any Slave Select for Master and Slave, does this mean i can use whatever i want? And just code it to detect that pin

Does the built in SPI library capable of handling the slightly higher clock speed of the zero ?


texts: Doorbell for someone with hearing issues

texts:
I have an Arduino Uno with the basic kit, not very good at coding it however.

How could I make a doorbell that lights up an LED instead of making a noise?

I'm trying to make a doorbell for someone with hearing issues.

A simple LED lighting up would be more than enough. Would I need a wifi shield if it's not close enough to be hard wired?

Thanks


texts: Does the StringObject.reserve() function prevent memory fragmentation/leaks?

texts:
I'm currently writing and testing a professional Arduino application, I'm aware of the dangers of using the String class, so I began to implement C-style strings in some places, but it's just way harder using them to receive data from a Software Serial port that's variable in size and needs some manipulation.

I've upgraded from an Arduino Uno to a Leonardo so my current minimum SRAM usage is 1325 bytes (51%)

Here's the relevant part of my code:

String serialContents;
char emailChar[SIZEOF_ARRAY][SIZEOF_CHAR];

void setup(){
  serialContents.reserve(70);
  SerialOne.begin(9600);
}

void loop{

  if (SerialOne.available() > 0) //something is there to be read
  {
    serialContents = SerialOne.readStringUntil('\n'); //make a string of the characters coming on serial
  }

  if (serialContents.length() >= 60)
  {
   serialContents = ""; //ignore serial data
  }
 else{
  serialContents = cutString(serialContents); //some String manipulation, no adding only cutting
  serialContents.replace("@", "%40");
  serialContents.toCharArray(emailChar[count], 31);
  serialContents = ""; //String reset
}

So my question is, does something like this make my code unstable? Does the
reserve() function help at all?

Edit: Here's the cutString() function

String cutString(String request) {

  int points = request.indexOf(':');

  if (request.substring(0, points) == "CHECKOUT")
  {
    modoPedido[count] = 'o'; //char array
  }
  else if (request.substring(0, points) == "CHECKIN")
  {
    modoPedido[count] = 'i';
  }

  request = request.substring(points + 1);

  return request;
}


texts: Very easy Arduino code challenge for you brainiacs to solve

texts:
I've searched the forum for similar problems and still can't see my obvious issue. I'm working on a simple Halloween prop and I'm using an Arduino for the first time. I've tested each individual 'event' (i.e. fog machine, mp3, actuator, and LED strip) with a loop and all four have worked on continuous loop with no issue.

As soon as I combine them all together, the program runs successfully exactly one time. After that final 10 second delay, when I expect the program to start the loop again, it crashes. If it helps, right during the start of the next loop, the relay light turns on on the relay board for RELAY_1_A and sort of just flickers while the actuator hums. I usually shut it down quickly at this point. As soon as I turn the system back on, it successfully runs through another iteration until the loop hangs.

I'm happy to provide pictures or even a video of the issue if that helps. My guess is that you guys will spot my coding issue right away. Maybe some kind of memory overflow or something like that.

I know my code could be much more efficient but I'm just looking for the glaring problem that is keeping the loop from working.

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

const int RELAY_1_A = 7; //the one with the issue
const int RELAY_1_B = 8;

SdFat sd;
SFEMP3Shield MP3player;
void setup() {
  // initialize the digital pins as an output.
  pinMode(10, OUTPUT); //Fog machine on Relay1 on 5V relay board
  pinMode(3, OUTPUT); //LED strip off breadboard MOSFET
   pinMode(RELAY_1_A, OUTPUT); //12V relay for actuator on Relay1 on 12V relay board
   pinMode(RELAY_1_B, OUTPUT); //12V relay for actuator on Relay2 on 12V relay board

  //start the shield
  sd.begin(SD_SEL, SPI_FULL_SPEED);
  MP3player.begin();
  MP3player.setVolume(10, 10);
}

void loop() {
  MP3player.playTrack(2);  // Play MP3. Track 1 is coffin and track 2 is bird
  delay(5000);              // wait for 5 seconds
  digitalWrite(10, LOW);   // Turns ON fog machine
  delay(3000);
  digitalWrite(10, HIGH);   // Turns OFF fog machine
  digitalWrite(3, HIGH);   // Turn the LED on (HIGH is the voltage level)

  delay(5000);              // wait for 5 seconds

  retractActuator();       //Open coffin
  delay (9000);
  stopActuator();      //Close coffin
  delay (9000);
  extendActuator();      //Close coffin
  delay(8000);
  digitalWrite(RELAY_1_B, HIGH);  //Turns off this relay during the wait period before next loop

  digitalWrite(3, LOW);    // Turn the LED off by making the voltage LOW
  delay(10000);              // wait for 20 seconds

}
void extendActuator() {
  //Set one relay one and the other off
  //this will move extend the actuator
  digitalWrite(RELAY_1_A, HIGH);
  digitalWrite(RELAY_1_B, LOW);
}

void retractActuator() {
  //Set one relay off and the other on
  //this will move retract the actuator
  digitalWrite(RELAY_1_A, LOW);
  digitalWrite(RELAY_1_B, HIGH);
}

void stopActuator() {
 //Set both relays off
 //this will stop the actuator in a braking
 digitalWrite(RELAY_1_A, HIGH);
 digitalWrite(RELAY_1_B, HIGH); }


texts: Arduino Won't Work With Sensors - Pulsates 1/HIGH when not plugged in, constant HIGH/1 when plugged in

texts:
simulate this circuit – Schematic created using CircuitLab

I tried to do a simple project where a 8x8 matrix lamp would display something different depending on whether or not a sensor outputted high/low.

There was no trouble getting the matrix lamp to work, as I wanted, but the sensor kept outputting 1, regardless if it was plugged in or not.

This is the code I used, but when I plugged in the sensor it would display 1/high continuously, and when I removed all wires from the sensor, the lamp would light occasionally and the monitor would display 1 as the movStat value.

The LED lamp is connected directly to the breadboard via. digital pin 4.

I am considering buying a new Arduino, but I would like to get a second hand opinion before I spend money on it.

I am using a PIR sensor model HC SR501:

int movSens = 3;
int ledPin = 4;
int movStat = 0;

void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
    //Sensor Setup
    pinMode(movSens, INPUT);
    //LED Setup
    pinMode(ledPin, OUTPUT);
}

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

    Serial.println(movSens);

    movStat = digitalRead(movSens);

    if (movStat == HIGH) { //If motion is detected, activate LED
        digitalWrite(ledPin, HIGH);
    }
    else {
        digitalWrite(ledPin, LOW);
    }

    Serial.println(movStat);
}


texts: How to send data in response to HTTP get request from ESP8266?

texts:
I'm trying to control some RGB LEDs with ESP8266. I have built an HTML page to set the color and send the RGB color code to the ESP using HTTP get request. Everything works as expected. I just want to send an HTTP get request to the ESP and ask what the current color is. But after a couple of hours of searching and trying I don't know how to send data in response to get request, I just can send HTTP ok code. I'm using jquery to send get command as below

$.get("http://192.168.4.1/rgb(120,50,60)", function(data,status){
    //I don't know how to send data fram ESP get it here.
});

this is the corresponding ESP response code written in Arduini IDE

WiFiClient client = server.available();
   if (client) {
  String req = client.readStringUntil('\r');
  client.print("HTTP/1.1 200 OK\r\n");
  client.print("Access-Control-Allow-Origin: *");
.
.
.

This is the HTTP header, How do I send some data(text)?


texts: NodeMCU v2 - Current when powering from VIN

texts:
I am working on a project and I want to directly power my NodeMCU from VIN. I have found lots of articles and questions talking about different voltages on the VIN pin of the NodeMCU, but almost none talking about max current input.

Now I am absolutely a bit of a Noob, so apologies if this is a stupid question.

Fundamentally I understand that I can wire a 5V supply to the VIN pin, and I have seen plenty of examples of 9V batteries and 12V supplies. I want to use a 5V3A supply and I am concerned that the 3A current may be too high as input and could fry the NodeMCU.

I just want to be sure that all the articles I have been reading are not talking about 5V1A supplies, and then I accidentally fry the NodeMCU :)

~Mick


texts: Adafruit_NeoPixel define pin for different setups

texts:
I am looking for a way of defining multiple pins for my RGB strips. Currently the defined variable is set with the pin within it. This works just fine if I only had one RGB strip connected to the Arduino but I have 4 so I will need to define.

I currently run this code here:

#include <Adafruit_NeoPixel.h>
#include <avr/power.h>

int rgb1 = 18;
int rgb2 = 17;
int LEDs = 11;
int ledFadeTime = 5;

Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(LEDs, rgb1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(LEDs, rgb2, NEO_GRB + NEO_KHZ800);

void setup() {
  strip1.begin();
  strip1.show(); // Initialize all pixels to 'off'
  strip2.begin();
  strip2.show(); // Initialize all pixels to 'off'
}

void loop() {
  rgbFadeInAndOutStrip1(0, 0, 255, ledFadeTime); // Blue
  rgbFadeInAndOutStrip2(255, 0, 0, ledFadeTime); // red
}

void rgbFadeInAndOutStrip1(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) {
  for(uint8_t b = 0; b <255; b++) {
     for(uint8_t i=0; i < strip1.numPixels(); i++) {
        strip1.setPixelColor(i, red * b/255, green * b/255, blue * b/255);
     }

     strip1.show();
     delay(wait);
  };

  for(uint8_t b=255; b > 0; b--) {
     for(uint8_t i = 0; i < strip1.numPixels(); i++) {
        strip1.setPixelColor(i, red * b/255, green * b/255, blue * b/255);
     }
     strip1.show();
     delay(wait);
  };
};

void rgbFadeInAndOutStrip2(uint8_t red, uint8_t green, uint8_t blue, uint8_t wait) {
  for(uint8_t b = 0; b <255; b++) {
     for(uint8_t i=0; i < strip2.numPixels(); i++) {
        strip2.setPixelColor(i, red * b/255, green * b/255, blue * b/255);
     }

     strip2.show();
     delay(wait);
  };

  for(uint8_t b=255; b > 0; b--) {
     for(uint8_t i = 0; i < strip2.numPixels(); i++) {
        strip2.setPixelColor(i, red * b/255, green * b/255, blue * b/255);
     }
     strip2.show();
     delay(wait);
  };
};

Which works when trying out just one out of the 2. But when the LEDs fade out it has a pause (i still see a hint of blue on the strip). If i comment all the code out for the second strip2 and run that, it pulses just fine without the hint of blue or the delay to start bright again.

What could I be doing incorrectly?


texts: How to use a common anode 7-segment, 4-digit display?

texts:
Please take this question as an example to (my own) answer below.

I've got an 7 segment, 4 digit LED display, but I don't have any idea on how to wire it.

I don't understand the difference between common anode/cathode, and I don't have 2 pins per LED, which is strange.
Quite recently, a question on a "7 segment 4 digit common anode" got deleted.
At that very moment I was typing an answer.

Though, I still want to share my answer with you, or the person who asked it.
Please verify/update my answer with more information.
Specifically, could someone add working code, I can't at the moment.


texts: Can I use L293D driver as ESC for arduino controlled quadcopter

texts:
I recently thought that it would be fun to build an arduino quadcopter.

As I did some research I realized that the common L293D motor drivers aren't ever used.

Why is this? Could I still use them in my project?


texts: I'm able to send messages from SIM800a module and receive "+CMGS: 177 Ok" but I'm not able to receive it in the number entered in the code

texts:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
char msg;
char call;

void setup()
{
  mySerial.begin(9600);   // Setting the baud rate of GSM Module
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  Serial.println("GSM SIM900A BEGIN");
  Serial.println("Enter character for control option:");
  Serial.println("h : to disconnect a call");
  Serial.println("i : to receive a call");
  Serial.println("s : to send message");
  Serial.println("r : to receive message");
  Serial.println("c : to make a call");
  Serial.println("e : to redial");
  Serial.println();
  delay(100);
}

void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
      SendMessage();
      break;
    case 'c':
      MakeCall();
      break;
    case 'h':
      HangupCall();
      break;
    case 'e':
      RedialCall();
      break;
    case 'i':
      ReceiveCall();
      break;
    case 'r':
      ReceiveMessage();
      break;

  }
 if (mySerial.available()>0)
 Serial.write(mySerial.read());
}

void SendMessage()
{
  mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  mySerial.println("AT+CMGS=\"+917018483787\"\r"); // Replace x with mobile number
  delay(1000);
  mySerial.println("sim900a sms");// The SMS text you want to send
  delay(100);
   mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
}

void ReceiveMessage()
{
  mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to recieve a live SMS
  delay(1000);
  if (mySerial.available()>0)
  {
    msg=mySerial.read();
    Serial.print(msg);
  }
}

void MakeCall()
{
  mySerial.println("ATD+917018483787;"); // ATDxxxxxxxxxx; -- watch out here for semicolon at the end!!
  Serial.println("Calling  "); // print response over serial port
  delay(1000);
}

void HangupCall()
{
  mySerial.println("ATH");
  Serial.println("Hangup Call");
  delay(1000);
}

void ReceiveCall()
{
  mySerial.println("ATA");
  delay(1000);
  {
    call=mySerial.read();
    Serial.print(call);
  }
}

void RedialCall()
{
  mySerial.println("ATDL");
  Serial.println("Redialing");
  delay(1000);
}


texts:
I am working on a system that starts a process based of a set time value (startHour). The user sets the start hour and can only select values from 00-23. I have been asked to start the same process at 6 hour intervals so that it occurs 4 times during the day.

My initial though is to add three more variable, secondStartHour, thirdStartHour and fourthStartHour. secondStartHour would be assigned a value 6 hours ahead of the startHour, thirdstartHour a value 12 hours ahead of startHour and fourthStartHour would be assigned a value 18 hours ahead of start hour. I could then use any of the startHour variables to trigger the process.

I wrote some code (below) that will work but I'm wondering if there is a better, more efficient way of doing it.

//set up secondStartHour 6 hours ahead of startHour
if (startHour <= 5)
{
    secondStartHour = startHour - 18;
}
else
{
    secondStartHour = startHour + 6;
}

//set up thirdStartHour 12 hours ahead of startHour
if (startHour <= 11)
{
    thirdStartHour = startHour - 12;
}
else
{
    thirdStartHour = startHour + 12;
}

//set up fourthStartHour 18 hours ahead of startHour
if (startHour <= 17)
{
    fourthStartHour = startHour - 6;
}
else
{
    fourthStartHour = startHour + 18;
}

I had to write the code in the way I did above because I am working with a 24 hour clock so in some cases adding time to a startHour will actually reduce the value. By this I mean if startHour is 23 (23:00) and I need to add 6 hours to it to get secondStartHour the result will be 5 (05:00) so I can't simply write code to say secondStartHour = startHour + 6. The code just seems too long winded and messy but I cant think of a better way to write it. I could use a switch case statement but then I would have 24 cases with assignments for each of the new variables in each case so that seems worse, any ideas would be appreciated.


texts: strcat gives error when I try to add a char to a char array

texts:
I have

char c;

where

int bt_available = Serial2.available();
if (bt_available) {
  c = Serial2.read();
}

and later in the code I try to

strcat(some_char_array, c);

and it gives me this error

  initializing argument 2 of 'char* strcat(char*, const char*)' [-fpermissive]
  error: invalid conversion from 'char' to 'const char*' [-fpermissive]

My best guess why the error appears would be that strcat can only accept strings and char arrays, but not single characters, so a solution I can think of would be to create a char array like char test[1] where test[1] = '\0' and then test[0] = c but I'm not sure if that's the best way to go about the problem and if that's a solution. Does 'const char*' mean 'char[]'?

P.S I read Majenko's blog thingy and I'm turning all Strings to char arrays and it's a bit of suffering :P


texts:
I'm using a DS1307 RTC (https://www.adafruit.com/product/3296) and an Arduino mega microcontroller trying to simply set and read the time of the RTC. However, whenever I try to output anything to the Serial Monitor, I get stuff like this:

The code and the wiring is fairly straightforward which is why I'm confused. I'm just directly attaching the Vcc, GRND, SCL and SDA pins of the clock to the Arduino and using a slightly modified version of the example code as a part of the RTC library Adafruit supplied.

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

RTC_DS1307 rtc;

void setup () {
  while (!Serial); // for Leonardo/Micro/Zero

  Serial.begin(57600);
  rtc.begin();

  rtc.adjust(DateTime(2017, 11, 17, 20, 33, 0));

}

void loop () {
    DateTime now = rtc.now();

    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();

    Serial.println();
    delay(1000);
}

So I know I'm doing something wrong but I'm not sure what. Any help would be hugely appreciated.


texts: Interfacing TRRS headphone to Arduino Uno

texts:
I have been working in a Arduino project lately which requires human voice input to Arduino with some processing Arduino need to perform specific task. Simple sampling of incoming signal and calculating average amplitude from it nothing complex.

My problem is I have tried using electret microphone to receive human voice input but failed since the Elec Mic is not sensitive to detect the voice even though i hooked up with LM386 amplifier circuit. So that option is out of the picture. Then i intend to use Android mobile headphones (TRRS) to receive the human voice which will provide great sensitivity for our voice.

Starting through simple internet searches i bought a product 3.5mm breakout module from Ebay. But am unsure of how to connect them to Arduino. Different sources in internet giving different information i couldn't figure out how to connect the headphone to arduino and read it's Mic output from headphone.

Seeing the pin out of TRRS headphones

i can't understand how could i possibly power my headphones with only GND pin available. I tried several wiring connections given in the internet to read the Mic output of my headphones through Analog pin A0 of Arduino but no luck so far. So my question is

1) How do i power the TRRS headphone using Arduino?

2) How can i read the MIC output of my headphone using Arduino? Is it even possible?
3) I have read somewhere the audio out from headphones will be of FSK modulated is it true?

Any help will be much appreciated. Please do provide if you have any links that might answer my questions.

Thanks in advance.


texts: GPRS shield - Hayes commands to identify a faulty SIM connection

texts:
I'm currently battling with a LinkSprite GPRS shield (it's based on the SIMCom SIM900 chip) and seem to have absolutely no luck trying to connect to the network.  I've got two SIMs, both of which should be active, but I cannot get the connection light on.

I've got a serial connection going and it's responding to various AT commands, but I can't connect:

  AT+COPS=?

is working, and giving me a list of networks, so I think my antenna is good, but

  AT+COPS=-whatever-

immediately gives me +CREG: 3.

I'm now wondering whether there's a fault with my board, and that it's not seeing the SIM cards.  A few commands that I thought would work aren't, for example:

  AT+CPIN?

just returns ERROR

Similarly, when trying to read SMS data:

  AT+CMGL="ALL"

returns ERROR.

Have I proved that the board isn't seeing the SIM, or is there something definitive I can try?

Thanks in advance!


texts:
I'm a beginner with Arduino and i have acquired the Arduino UNO R3 board. i have followed the instructions on arduino website in order to install the board, however it fails and still remains as an unrecognised device.

consequently, arduino IDE reports that COM1 is not found, and the 'ports' menu is grayed out.

steps i have tried:

1) install the Arduino 1.0.5 IDE
   - the installation failes near the end when installing the arduino board
2) install the Arduino 1.5.7 BETA IDE
- the installation is successful but arduino device is still unrecognized.
3) i have tried manually installing the drivers by letting windows search in the arduino IDE installation folder/drivers/
- it reports that the best driver is already installed - "usb unrecognized device"
4) i have tried installing the drivers by manulally loading the .inf files from the IDE installation folders, and installing all the serial converter A/B/C/D in the list - all failed to install.

i have done all the above for both IDE 1.0.5 and 1.5.7b with windows installer And zipped files, under administrative rights in windows 8.1

How do i get this to work?


texts: What is the output of Software Serial .read() function

texts:
Hi I am new to arduino development i was using esp8266 using software serial library

  here is the code

#include<stdlib.h>
#include <SoftwareSerial.h>

SoftwareSerial monitor(2, 3); // RX, TX

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

  sendDebug("AT");
  delay(5000);
  Serial.println("Hello");
  if(monitor.find("OK"))
  {
   Serial.println(monitor.available());
   Serial.println((int)monitor.read());
   Serial.println((int)monitor.read());
    Serial.println(monitor.available());
   Serial.println("RECEIVED: OK");
    //connectWiFi();
  }
  else
  {
    Serial.println("RECEIVED: None");
  }
}

void loop(){

}

void sendDebug(String cmd){
  monitor.println(cmd);
  Serial.println("Command: "+cmd);
}

  Output

Command: AT
Hello
2
13
10
0
RECEIVED: OK

All I know is monitor.available() return the available bytes that can be read and i can also deduce that these two bytes are O and K but the integer value doesn't corresponds to the ascii value of O and K

can anyone explain what is actually getting printed on the serial monitor what is 13 and 10 ? ??


texts: My 1604 LCD is bright with USB power but not when powered through the jack

texts:
I'm making a bench PSU. The Arduino runs off the purple 5v standby. The Mega also powers 2 LEDs (normal 5mm clear). The thing is, when I upload the code and watch the screen go through the process, it's bright and visible. But when I turn on the 5v standby (without USB) the text is visible if you try really really hard to see.

The 5v standby is rated at 2 amps MAX. I can't imagine it's the code but would anyone help? Why does USB power allow the LCD to power fully compared to the 5v standby?


texts: Analog reading with noise - Arduino Uno VS ESP12e

texts:
I was testing analog output from a microphone (Max9814) with an Arduino Uno, which came with nice results. The output provided by the microphone is converted into sound and is loud and clear.

Setup: (Max to Uno)

Pin Vdd to 3,3V
Pin GND to GND
Pin Out to A0

However when I tried to set it up with an ESP12e instead of an Uno, I got a lot of 'noise' and no clear sound at all.

Here I used the following setup: (Max to ESP)

Pin Vdd to VCC (VCC is measured at 3.3v with a multimeter)
Pin GND to GND
Pin Out to AD0

A little 'side step'

The problem arised that the analog output from the microphone delivered a voltage of around 1.24, while the ESP12e analog has 1v as max input. This made the analogRead max out all the time. For this reason I put a 10k OHM resistor between the OUT and AD0 combined with a 20k OHM resistor between gnd and AD0. This resulted into nice analog readings (instead of 1024, around 400-500 all the time).

However, like mentioned before, a lot of noise is in between and the sound is not clear. (I also tried to work with 'sample windows', here is the 'filtering mechanism' which can be found on many sites/questions and works perfectly fine):

//(global logic is set to take n samples and than print the line)
//Tried n of 5 to 20
//Also instead of just samples tried the micros variant instead of just samples which is also found on many sites to create a time window to record.
unsigned int sample = analogRead(A0);
if (sample < 1024) {  // toss out spurious readings
  if (sample > signalMax) {
    signalMax = sample;  // save just the max levels
  } else if(sample < signalMin) {
    signalMin = sample;  // save just the min levels
  }
}

unsigned int peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
Serial.println(peakToPeak);

Does somebody have a clue why the Arduino gives such clear and good sound, while the ESP12e does not. (The analog values do not 'seem' to differ much in the levels)


texts: 7 segment 4 digit not showing numbers 2,3 and 0

texts:
https://www.instructables.com/Using-a-4-digit-7-segment-display-with-arduino/
I used this link to make my circuit and I used this code also but some numbers like 2,3 and 0 doesn't display correctly.


texts: Strobe Frequency Calculation, how its done?

texts:
I'm using the Arduino sketch for LED stroboscope found here: http://mehax.blogspot.co.uk/2011/02/arduino-stroboscope.html.

Also below, I've inserted the loop part where this calculations are made:

void loop() {
// this while is a workaround for timer limitations using micros vs millis
sensorValue = analogRead(analogInPin);   //take potentiometer reading
hold = sensorValue*55 + 400;             //add some time to scale and for code execution
microsCurrent = micros();                // collect current time
if (microsCurrent > microsPrev + hold){  //set up timing loop
frequency = 1000000/(microsCurrent - microsPrev);
microsPrev = microsPrev + hold;            //set up millis for delay stuff

//set all 6 LEDs high (they were already plugged in)
digitalWrite(3,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
delayMicroseconds(.02*hold);  //leave LEDs on long enough to see

//set all LEDs low
digitalWrite(3,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);

if(millis() > millisSerial + 200){
  millisSerial=millis();    //reset timer
  holdFrequency = 1000000/hold;
  //do some math to find values
  rpm = frequency * 60;

I want to use this code in my project, but I don't really understand how this code calculates the stobing frequency.

So, I have following questions:

Why "hold" variable is calculated in the given way?
Why "microsCurrent", "microsPrev" and all other timings are executed?
How "frequency is calculated"?
What is "hold frequency" variable?

Sorry, I'm very new to Arduino and don't know much coding.
Will appreciate very much your help!


texts:
I followed the sketch example for the SEN0159 CO2 sensor as precised in the data sheet  https://www.dfrobot.com/wiki/index.php/CO2_Sensor_SKU:SEN0159. It's powered by a 9V/2A DC power supply more than 48h and it still reads 2.81V on the analog ouput pin even if i exhaust on the sensor during long time, nothing happen, giving - 1ppm CO2 value.

Can you explain me why i cannot observe CO2 variations ? Is there troubles with the board ?

Thanks!


texts:
Hi i'm trying to parse JSON resposne from webserver in my arduino in order to turn on and off a LED light. I'm using the wifi client repeating example to make a get request to my server:

http://arduino.cc/en/Tutorial/WiFiWebClientRepeating

Here is what I get printed back from the serial port

connecting...
HTTP/1.1 200 OK
Date: Sun, 06 Apr 2014 01:14:37 GMT
Server: Apache
X-Powered-By: PHP/5.5.10
Cache-Control: no-cache
X-Frame-Options: SAMEORIGIN
Set-Cookie: expires=Sun, 06-Apr-2014 03:14:37 GMT; Max-Age=7200; path=/; httponly
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json

19
{"lightstatus":"on"}
0

How do i parse the JSON portion of this response only so that I can use it to control my LED?

Thanks