texts: Bluetooth HC-05 module returns encoded data

texts:
I have searched online, and haven't found anyone hitting this issue. Strangely my Bluetooth HC-05 is returning encoded data. I have tried using different boards - Induing, Uno, Freeduino and I have the same problem with them all.

The Bluetooth module I am using is a HC-05 Bluetooth Module.

When I pass 'AT' command, I expect the return to be 'OK'. I get data as

CF  A7  86  85

This is 8-bit data, and if I drop the MSB I would be:

4F  27  06  05

Instead I should have received:

4F  4B  0D  0A

I looked at the binary pattern to understand if this is something like 7 bit encoding used in GSM.

Actual Data
CF       A7       86       85
11001111 10100111 10000110 10000101

Expected Data
4F  4B  0D  0A
01001111 01001011 00001101 00001010

I have tried other AT commands and everything appears to be encoded.

The code I have written is pretty standard, module is blinking at 2 sec pulse (in command mode). I get encoded output for all AT commands. I even tried ORGL, INIT and other commands as suggested on various discussion threads.

#include <SoftwareSerial.h>

SoftwareSerial BtDongle = SoftwareSerial(10, 11);

void setup() {
  digitalWrite(9, LOW);
  delay(100);
  digitalWrite(9, HIGH);
  delay(100);
  Serial.begin(9600);
  Serial.write("AT Command: \n\n");
  BtDongle.begin(38400);
}

void loop() {
  while(BtDongle.available()) {
    unsigned char data = BtDongle.read();
    Serial.println(data, HEX);
  }

  while(Serial.available()) {
    char data = Serial.read();
    Serial.print(data);
    BtDongle.print(data);
  }
}


texts:
Im a very beginner with Arduino. Recently started with the blink code. Thats my only experience with these. Ive got an ultrasonic sensor (As in this tutorial http://howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-sr04/). So I setup the connections as trigger to Pin3 , Echo to 4, Vcc to 5v marked pin, GND to gnd next to 5v. Im using Arduino nano clone. When I run the program same as in the above example Im getting the following error. Other than that Im not getting any information.

Im sharing the same program I tried.

// defines pins numbers
const int trigPin = 3;
const int echoPin = 4;
// defines variables
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
}
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
}


texts:
I'd like to connect 12 mpu9250 sensors to one arduino board.

I can't find documentation on how to change the addresses of mpu9250 boards. (i read through the reference ). Some tutorials talk about changing addresses for other device so i assume it is possible for mpu9250. I found this map of registers but can't figure out how to change the address.

I realize that mpu9250 might be too specific, so general guidance on how to solve these problems would be highly appreciated.

mpu9250 is similar to more popular mpu9150 and mpu6050. It is also known as GY-9250


texts:
I want to ask about Wemos d1 R1. Can I use those pins connected for different sensor?

For example I use pin D5 and D13 for switch and push button, or I use pin D7 and D11 for two different sensors.

Thanks.


texts:
I have code for an ultrasonic sensor which I found from a site. Here is the code:

#define trigPin 12
#define echoPin 13

void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {
  int duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  if (distance >= 200 || distance <= 0){
    Serial.println("Out of range");
  }
  else {
    Serial.print(distance);
    Serial.println(" cm");
  }
  delay(500);
}

However, I don't understand the work of pulseIn() function. I mean, I want to know when the time count starts and when it ends. For example, in this code, does the time start at digitalWrite(trigPin, HIGH); or does the time start at the pulseIn() function?

If it's the second one, when it stops, then how does the time give us the distance of an obstacle when I am already delaying 1000 microseconds after I send a ping in air?


texts: Sending response to a GET request from an ESP8266

texts:
I'm exploring the ESP8266 for a home automation project.
I setup a server in WiFi mode 1 using these commands:
(AT+CIPMUX=1,AT+CIPSERVER=1,80.)
I assigned a static IP for the MAC address in my router settings.
I managed to send a get request from HTML page using jQuery $get() to the ESP module. I'm only using AT commands via serial monitor.
I hooked it with Arduino and using serial monitor to send AT commands.
+IPD,0,314:GET /?pin=10000 HTTP/1.1
Host: 192.168.0.100
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Mobile Safari/537.36
Origin: null
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9

This is the part in the HTML page that sends this request. It is supposed to give an alert after receiving data from server:
<script>
      $(".button").click(function(){
        $.get("http://192.168.0.100:80/", {pin: 10000} , function(data, status){
    alert("Data: " + data + "\nStatus: " + status);
  });
        });

    </script>

I used AT+CIPSEND=clientid,length and entered the data I wanted to send
AT+CIPSEND=0,8

OK
>

busy s...

Recv 8 bytes

SEND OK
AT+CIPCLOSE=0

0,CLOSED

OK

This error is displayed in console:
Access to XMLHttpRequest at 'http://192.168.0.100/?pin=10000' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

GET http://192.168.0.100/?pin=10000 net::ERR_FAILED

I want to send a response for the request and I'm totally new to HTTP requests.


texts: CLion + Arduino -- Cannot find any CMake profile

texts:
I'm trying to get CLion 2019.2 working with Vladimir Schneider's Arduino Support plugin (v1.4.4, from the Jetbrains Plugin repository)

I installed MinGW from https://sourceforge.net/projects/mingw/ into c:\mingw, then went to Settings -> Build/Execution/Deployment -> Toolchains, added a new MinGW toolchain from c:mingw, and allowed it to autodetect make, gcc, and g++.

I got an error that GDB was too old,  selected "use bundled GDB", and the error went away.

I then created a new Arduino/Genuino Uno project, and attempted to build it.

At first, I was getting CMake Error at CMakeLists.txt:5 (set), due to line 5 being "set(${<@PROJECT_NAME@>}_BOARD uno)".

I found a post in the Arduino plugin's bug tracker said it's a bug in the plugin, and the work-around is to hand-edit CMakeLists.txt to replace every instance of "${<@PROJECT_NAME@>}" with "{PROJECT_NAME}" (apparently, there's a bug somewhere that causes it to wrap some environment variables with <@ and @>).

Now, I'm getting a different error whenever I try to build: "Cannot find any CMake profile"

I think I remember seeing a bug report thread for CLion itself speculating about the existence of a bug in CLion where the preferences UI implies that a configuration change has been made, but CLion doesn't actually update the file used by CMake to reflect the change. From what I recall, someone in the thread asked what specific file needed to be changed, and what specific changes were necessary... then the thread died without any subsequent posts for the past ~6 months.

Any ideas about what to try next?

Other relevant links for background info & context:

CLion's Arduino plugin by Vladimir Schneider: https://plugins.jetbrains.com/plugin/11301-arduino-support

Vladimir's project is a fork of an earlier plugin that was apparently broken by the release of CLion-2018.1. I'm under the impression that it still works for CLion 2019 under Linux, but was either broken by 2018.2 or 2019.1 for Windows, or never quite worked properly under Windows at all.

I've gotten the impression that, at least as of 2017-2018 (which is when a large number of postings about CMake-under-MinGW/Windows, CLion, and Arduino were made), CMake under Win32 via MinGW was still kind of buggy and brittle. The number of postings about them in 2019 is a lot smaller than 2017 and 2018, but I'm not sure whether that's because the problems people were talking about 2 years ago were solved, or because the people talking about them 2 years ago just got frustrated, decided it was a bit too bleeding-edge for them, and (at least temporarily) threw in the towel to wait for them to mature a bit.

Update: I just found another post theorizing that some of these problems might be due to limits imposed by Windows (by default) on the number of characters allowed in filename paths. I know Windows 10 allows you to increase the limit, but I know there are still a bunch of issues associated with doing that (Explorer can't touch anything with a path > 260 chars, cmd.exe -- and possibly Powershell -- requires using \\?\ notation, and Very Bad Things™ will happen if you physically attach a hard drive with files whose pathnames exceed the limit to a different computer running Windows that's still enforcing the old limit).

A tutorial for it that unfortunately seems to have gotten broken slightly by a subsequent release of CLion or one of its Arduino dependencies: https://vxlabs.com/2018/03/24/developing-arduino-sketches-with-jetbrains-clion-a-minimal-example/

(note to mods: I tried to tag this with "CLion" and "CMake", but the tags don't already exist, and my reputation isn't high enough yet to create new ones)


texts: Detecting Ultrasonic sensor malfunction within the arduino sketch

texts: Is it possible to write code in the sketch that checks the functioning of the ultrasonic sensor? Say if the sensor stopped working then the arduino will alert the user in the serial monitor.


texts:
There is a tutorial in the Arduino website on how to create a library. The tutorial gives the following codes for the header:

class Morse
{
  public:
    Morse(int pin);
    void dot();
    void dash();
  private:
    int _pin;
};

My questions are:

What is the purpose of this line: Morse(int pin);
If any, what is the name of this line?


texts:
I'm trying to use my 30A ACS712 on my OSD (it has ATMEGA16L).

But it is very unstable, 0 amps goes from 450 to 445, but that isn't that bad, but when I put 10A of current through it jumps from 440 to 380.

I already searched on google and tried to add filter cap between acc and gnd, but it didn't help and acs712 and osd have different power supply than the load.

Any help is welcome.


texts: How can I control 2 servos without an external power supply?

texts:
I've been trying to implement a project that's been in my head for a while, I want to wirelessly control my light and fan switches using an ESP32 and 2 servos (one for each switch) through an HTML page, and then later integrate it with Alexa
I have seen how one servo can be controlled by connecting the servo's power cable to the ESP32's Vin pin, but how can I control two? I want to avoid using an external power supply like a battery pack because I want it to be a completely automated process, and I don't want to have to keep switching out batteries often for the thing to work. I'll be using a 5V wall outlet to power the ESP32 using a USB.
Also, if anyone can provide a few more tips on how I can make my project more efficient or point out where I might be making a mistake, I'd be glad. I'm still new to the microcontroller world.
Thanks
EDIT :  I've attached a picture of the circuit diagram, just have a look and let me know if it is workable


texts: How do I synch the Arduino PID library with an external timer for turn-rate control?

texts:
I have been trying to use the Arduino PID library for controlling the rate of turn (in deg/sec) of a wall-following robot.
The robot's operating system uses TIMER5 on an Arduino MEGA2560 to update a number of time-sensitive parameters (heading, front/back/left/right distances, etc) which are used throughout the code. For turn rate control, the difference between the current and previous headings (appropriately modified for 0/180 transitions) is multiplied by 10 to get deg/sec, and then this value is the 'input' to a PID. The PID output is a speed control to the wheels to achieve the desired turn rate setpoint.
Unfortunately, the current Arduino PID library has an internal timer (that can be changed, but not disabled) which has it's own idea of time.  In addition, the PID library's internal timer isn't available to the outside world - it is only used in PID::Compute().
The typical code configuration for using a PID is something like the following:
loop()
{
    //lots of other stuff
    if(TIMER5 ISR has been triggered)
    {
        //compute turn rate = 10*delta_heading
    }

    if(myPID.Compute()) //the internal timer is used inside this function
    {
       //use the PID output to control something (like wheel speeds)
    }
}

loop() runs at max speed, but myPID.Compute() only generates a new output when the internal PID timer elapses (otherwise it returns immediately without doing anything).  However, the turn rate input is being computed on a different schedule, leading to unpredictable behavior.
A possible solution is:
loop()
{
    //lots of other stuff

    if(myPID.Compute()) //the internal timer is used inside this function
    {
        New_Hdg_Val = GetNewHdgVal();
        turn_rate = ComputeTurnRate(New_Hdg_Val, Prev_Hdg_Val);
        Prev_Hdg_Val = New_Hdg_Val;

       //use the PID output to control something (like wheel speeds)
    }
}

So now the turn rate is computed on the same time intervals as PID::Compute(), which looks OK, as long as the timer value being used by the PID is the same as the TIMER5 ISR value being used by the rest of the program; clunky, inelegant, but maybe OK.
Unfortunately, because the PID computes a new output value inside PID::Compute(), the new value computation comes BEFORE the turn rate computation, which means the turn rate being used to produce the new output uses turn rate information that is AT LEAST 100mSec out of date (assuming the default 100mSec PID sample time setting) - ouch!!
So, how do others use the Arduino PID library in systems with an external (to the PID library) timing source?


texts: TPIC6B595 Output Unable to Allow Supplied Power to 7-segment Display

texts:
We have an Arduino Nano connected to 4 small (0.5") common-anode 7-segment displays and 2 large (3") common-anode 7-segment displays. We are trying to multiplex the displays. The larger one requires more power than the smaller one (9V) which the shift register cannot supply.
Therefore, we have supplied 9V to the open drain outputs of the shift register that are connected to the larger displays with a pull-up resistor (390ohm). However, more power (7.5V) goes to the resistor than the display (1.5V).
They are connected like in the ShiftDisplay library's schematic, with a pull-up resistor added according to this link on open drain.
How do we use the open drain outputs logic to supply power to the display?
The data sheet of the big 7-segment display can be found here. Each display requires 160mA of continuous current.


texts:
I just hooked up a DHT22 I had laying around in a parts drawer to test something and it is giving out some crazy wrong values, I am running the adafruit library's unified example and this is the output:

Resolution:   0.10%
------------------------------------
:   1
Unique ID:    -1
Max Value:    100.00%
Min Value:    0.00%
Resolution:   0.10%
------------------------------------
DHTxx Unified Sensor Example
------------------------------------
Temperature
Sensor:       DHT22
Driver Ver:   1
Unique ID:    -1
Max Value:    125.00 *C
Min Value:    -40.00 *C
Resolution:   0.10 *C
------------------------------------
------------------------------------
Humidity
Sensor:       DHT22
Driver Ver:   1
Unique ID:    -1
Max Value:    100.00%
Min Value:    0.00%
Resolution:   0.10%
------------------------------------
Temperature: 588.80 *C
Humidity: 998.40%
Temperature: 563.20 *C
Humidity: 1049.60%
Temperature: 563.20 *C
Humidity: 1024.00%
Temperature: 563.20 *C
Humidity: 1024.00%
Temperature: 563.20 *C
Humidity: 1024.00%

Had anyone seen behaviour like this before? of course my room isn't 600 *C or 1000% humidity XD

Its connected to an arduino UNO that I am pretty sure works fine.


texts: Is it possible to create a infrared based interruption counter with an Arduino Uno? If yes, then what additional hardware would be necessary?


texts: Confusion with storage of declared variables and volatile

texts:
I read that volatile is used when we want to store variables in SRAM.

But aren't all the variables in a code are stored in SRAM anyway?

And what makes it an advantage sometimes for variables(like volatile) to be stored in SRAM?


texts: I want to be able to upload a batch of tweets to a twitter bot to be qued' for tweeting

texts:
I have built a twitter bot with my Arduino and an Ethernet shield
right now, the way to make it tweet something is to manually add a phase into the code and upload it to the board for each new tweet,

I would like to create a simple way of scrolling through a queue of phrases and tweeting each consecutive one after a given amount of time (several hours).
the issue I'm seeing is that, the code needs to rerun for each tweet, and I can't figure out what needs to be in what loop. Also the entire thing needs to delay for 3.6e^6(1 hour) milliseconds (the code takes delays in milliseconds) so that I don't spam the feed,
the twitter for this project is @ether_bot.

Code is below:

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

/*
void speech()
{
  //this is where i would put the que of tweets
}
*/

// the next three lines connect the ethernet shield to the local network and establish a link with the twitter account
byte ip[] = { 192,168,1,104 };
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEU }; //address for the shield
Twitter twitter("2790106893-5ljE7WPyyGe16SqTMEm8CN5gpwDquhGnyjH2TCM");
char msg[] = "hello again, im getting some major work done soon!"; // message to tweet

void setup()
{
  delay(30000);
  Ethernet.begin(mac, ip);  // makes the connection
  Serial.begin(9600); //opens a serial interface similar to the prnt window in bluejay
}

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

  if (twitter.post(msg))
  {
    int status = twitter.wait();

    if (status == 200)
    {
      Serial.println("OK.");
    }
    else
    {
      Serial.print("failed : code ");  //stuff happens here idk
      Serial.println(status);
    }
  }
  else
  {
    Serial.println("connection failed.");
  }

  do {} while(1);
}


texts:
I have a problem with stepper motor direction.

I want to change the direction of the stepper motor rotation, when the stepper motor shaft is stuck.

For example, when I hold the shaft of the stepper motor with my hand, the direction should change.

How can I do it?
Someone told me you should calculate the current, but I don't know how to do this?

My material components:

Arduino
stepper motor gearbox 12 V
ULN 2003A


texts:
So i have struct:
typedef struct sendPacketStruct {
  byte header = headerByte;//0x55
  unsigned int time;//2 bytes
  int height;//2 bytes
};

And i do this:
    sendPacketStruct sendPacket;

    sendPacket.time = 84;//0x54
    sendPacket.height = 100;//0x65

    Serial.write((byte*)&sendPacket, sizeof(sendPacket));

But when i receive it at the other end the hex bytes are:
55 54 00 64 00
So the first byte is correct as the header 0x55, but the 2x 2 byte values time and height are there but shifted.
eg it should be 00 54 not 54 00


texts: Velocity from Sensor Data - Best Approach?

texts:
I am attempting to develop a control system based upon rocket velocity. My first step is attempting to properly filter my sensor data in order to calculate velocity.

What is the best approach to get accurate, smooth, and fast data to my control logic?

Would I benefit from combining accelerometer and barometric data? If so, how?

Background:

I am currently only using a BMP180 barometer to get altitude and then calculating velocity from the last altitude measurement. I am operating the BMP180 on ultra low power to increase the sample rate, but that comes at a cost of a RMS noise of around 0.5 meters.

Using 1D Kalman filtering I can get it smoothed out somewhat (tried on both velocity and altitude), but it is still not anywhere near as smooth as I need for my control system. It also lags behind the data far too much when I get it smoothed.

I have attached an example of what I have done with Kalman filtering. The original data is from a Featherweight Raven altimeter. I used the reported altitude data to calculate velocity (standard deltX/deltT) for each iteration, filtered it, and compared it with the Raven's own calculated velocity from it's accelerometer. The altitude data is at 20 Hz which is about what I am achieving with my Arduino setup right now.

Thanks!


texts: Would it be feasible to build an arduino that takes 12v on/off signals from a vehicle diagnostic port (1984 pre-OBD)?

texts:
The vehicle is an AMC eagle, they come with a diagnostic port
I have made a diagnostic tool that lights led lights when signals turn on and off, but it has to be wired in and is bulky. I am wondering if it would be possible to have an arduino plugged in and running off the 12v battery supply (with step-down to 5v) and have it catch the signals and send them over Bluetooth to a computer. Does this sound like it is within the scope of an arduino or am I asking too much? Or is there a better and easier way to do this?


texts:
I was wondering if this can be done. I got a Nokia 106 and am trying to make it talk, but the audio jack doesn't seem to cooperate and the Fbus pins are right under the SIM slot, which is right under the battery. Any advice?

Added: It seems that it talks AT commands, since it is a GSM model, but I'm not 100% positive.


texts: Why can't I declare a class in another tab in Arduino IDE?

texts:
I wanted to move some of my code out into a second tab in the Arduino IDE, to keep things better organised. At first, I only tried moving a function, and it seemed to work fine. I could call the function from the setup() function in my main tab, and there were no problems compiling or uploading.

However, I tried putting a whole class into the second tab, and suddenly it didn't work any more. For example:

Tab 1:

TestClass obj;

void setup()
{
    obj.init();
}

void loop()
{
    //...
}

Tab 2:

class TestClass
{
public:
    void init()
    {
        //...
    }
};

When I tried to compile this, it gave me the following errors:

tab1:1: error: 'TestClass' does not name a type
tab1.ino: In function 'void setup()':
tab1:5: error: 'obj' was not declared in this scope

Why does it recognise a function in another tab, but not a class? Is there a way to make it work in the Arduino IDE, or do I need to use an alternative like Eclipse?


texts:
I have a DotStar LED strip that I want to make it blink (e.g., 1 second on, 5 second off in an endless loop).

I tried doing so via the script below but it does not work. Can someone please explain me how to do so?

Script:

#include <Adafruit_DotStar.h>
#include <SPI.h>

#define NUMPIXELS 10

#define DATAPIN    4
#define CLOCKPIN   5
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);

void setup()
{
  strip.begin();
  strip.show();
}

void loop()
{
  strip.show();
  strip.setBrightness(155);
  for (int i=0; i <= 10; i=i+1) {
    strip.setPixelColor(i, 255, 255, 255);
  }
  delay(1000);

  strip.setBrightness(0);
  delay(5000);
}


texts:
I made a small little IoT device to control my light chains from my phone, I'm using a MOSFET to turn the power on or off, using an esp32 connected to the MOSFET, both esp32 and light chain is supplied from a standard 6v phone charger I just clipped the wires and used it,
I have a voltage regulator on the esp32 as seen on the image, when I run the system the esp32 slowly heats up to around 40-50 Celcius, and I can hear a small whinny sound from the chip, the esp32 is getting 3.3v as I should when I measure with a multimeter
what's wrong?
(btw it works with turning lights on and off, not sure if those was the resisters i used)


texts:
Having this basic example for using the SerialUSB function on the Arduino Due under Windows:
// ARDUINO DUE BLINK LED
void setup(){
  pinMode(13,OUTPUT);
  SerialUSB.begin(2000000);
  while(!SerialUSB){
    digitalWrite(13,HIGH);
    delay(100);
    digitalWrite(13,LOW);
    delay(100);
  }
}

void loop(){
  SerialUSB.println("Hello, World!");
  digitalWrite(13,HIGH);
  delay(100);
  digitalWrite(13,LOW);
  delay(900);
}

I am having trouble understanding which shall be the operating sequence for this use. Normally I follow these steps:

Open Arduino IDE, select Arduino Due (Programming Port) at COM 01, and connect it to PC USB,
Compile and Upload the code,
Open a Serial Monitor App, with COM 02, 2000000 bps or 9600 bps, 8b data, 1b stop, no parity, RTS|CTS flow control.

If I keep the Arduino connected to the Programming Port after trying the Native USB Port, I have to disconnect and connect everything to program it again (??), or disable it through the windows Device Manager.
Which is the proper sequence (and perhaps the code) for doing this the right way?.


texts: Flow control between ESP32 and RS323 device

texts: I'm trying to communicate an RS232 device with an ESP32 (Heltec Wifi/LoRa 32 v2) my problem is that I don't receive any response from the device, doing some research, I'm thinking that the trouble can be the flow control because I don't use these pins and the modules I've used neither have these pins. Do you know a way to, at least, solder the DB9 pins to have a sort of flow control to communicate the devices?


texts: Communication between 2 arduino's one at 6th floor and the other at the basement

texts:
Communication between 2 Arduino's one at 6th floor and the other at the basement.

I tried with nodemcu , but the signal is not reaching the basement. From 6th floor.

Which is the best way to connect?.

I have a couple of nRF24L01 with antennas, does nRF24L01 works in this case?

How about hc-12. I have seen tests with line of sight's only.  But in this case, I have an elevation of about 80 feet and also some horizontal distance.

Basically, I wanted to implement wireless water level measurement for our overhead tank inside our apartment.

Regards
ravi


texts:
Clearly, an Arduino can be powered with solar panels.

What is the most optimal configuration?
Can you recharge and discharge at the same time?
Is LiPO the best battery cache technology, or is there something more durable out there, for fielded deployment?
What are the most economic, and reliable ways to do this?


texts: How to use attachInterrupt() in ATtiny85 with Arduino IDE?

texts:
It's possible use external interrupts/attachInterrupt() with the ATtiny85 when I program with Arduino IDE?

If is possible, how many inputs (for external interrupts) the ATtiny85 have and which are they?
Someone have an example code?


texts: BMP280 pressure as a DC motor switch - issues

texts:
I'm attempting to control a DC vacuum pump to turn off when it hits a BMP-280 reads a set pressure lower than when it spins up (guesstimate pressure, I've got it hooked up to tweak in person). Everything works fine for pressure until I get to the runPump() subroutine, when the pressure callouts go from pascal to very large odd numbers.  I've tried variations of INT/FLOAT/LONG but I still either get a 0 pascal reading or an OVF. The BMP later in runPump does return pressure in pascal.

#include <Wire.h>    //This library allows you to communicate with I2C devices (BMP280)
#include "i2c.h"     //same
#include "i2c_BMP280.h"   //same
BMP280 bmp280;
int inches = 0;
int motorPin2 = 10;
int motorPin1 = 9;
int triggerPin = 7;  // For ultrasonic sensor
int echoPin = 4;    // For Ultrasonic sensor
long duration;
long distance;

void setup() {

  pinMode(triggerPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);

  Serial.begin(9600);
  Serial.print("Probe BMP280: ");
  if (bmp280.initialize()) Serial.println("Sensor found");
  else
  {
    Serial.println("Sensor missing");
    while (1) {}
  }

  // onetime-measure:
  bmp280.setEnabled(0);
  bmp280.triggerMeasurement();
}

void trig() {
  Serial.println("Ping!");
  digitalWrite(triggerPin, LOW);
  delay(2);
  digitalWrite(triggerPin, HIGH);
  delay(10);
  digitalWrite(triggerPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  inches = (duration / 2) / 74;
  Serial.print("Inches: ");
  Serial.println(inches);
  delay(250);
}

void runPump() {
  //  Serial.println("Running Pump!!!!!!");
  //  #include <Wire.h>    //This library allows you to communicate with I2C devices (BMP280)
  //  #include "i2c.h"     //same
  //  #include "i2c_BMP280.h"   //same
  //  BMP280 bmp280;
  //  int motorPin1 = 10;
  //  int motorPin2 = 9;

  bmp280.awaitMeasurement();
  float  pascal;
  bmp280.getPressure(pascal);
  bmp280.triggerMeasurement();

  float runningpressure;
  float deflatepressure;
  runningpressure = (int) pascal;
  deflatepressure = (runningpressure - 600); //pascal minus a bit
  Serial.print("Starting pressure: ");
  Serial.println(pascal);
  Serial.print("Goal pressure: ");
  Serial.println(deflatepressure);

  while (runningpressure > deflatepressure) {
    Serial.println("Engaging Vacuum Pump!!!");
    digitalWrite(motorPin1, HIGH);
    digitalWrite(motorPin2, HIGH);
    delay(250);
    bmp280.awaitMeasurement();
    bmp280.getPressure(pascal);
    bmp280.triggerMeasurement();
    Serial.print("Current pressure: ");
    Serial.println(runningpressure);
    Serial.print("Goal pressure:");
    Serial.println(deflatepressure);
    Serial.print(runningpressure - deflatepressure);
    Serial.println(" more to go.....");
    delay(250);
  }
  //  else{
  Serial.println("Shutting Down!!!!!!!!!!!!!!");
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  delay(2000);
  //  }
}

void loop() {

  bmp280.awaitMeasurement();
  float  pascal;
  bmp280.getPressure(pascal);
  bmp280.triggerMeasurement();
  Serial.print("Pressure: ");
  Serial.print(pascal);
  Serial.println(" Pa;");
  trig();

  if (inches > 4 && inches < 10) {
    runPump();
  } else
    digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  delay(5);
}

//  Serial.println("Extruding Glove!@!!!");
//  digitalWrite(motorPinR, HIGH);  //extrudes gloves
//  delay(500);                      // waits .5 seconds
//  digitalWrite(motorPinR, LOW);   // stops extruding


texts: Arduino with Ethernet Shield with PC to upload data to Microsoft Azure

texts:
i am a student doing a project related to datalogging. My project is a rehabilitation device that uses 2 rotary encoders to record data for rotation and linear movement of a human arm. The data extract is store inside the PC, but my supervisor wants me to upgrade it, he gave me an Arduino Ethernet Shield to attach it on Arduino Mega and he wants me to upload the data obtained from the device to Microsoft Azure database. I'm still new in both Arduino Ethernet Shield and Azure...can anyone help me?

What can i do with the Ethernet Shield? I mean we normally use the USB cable to work with Arduino, so this mean I have to connect both?

Thanks in advance!


texts: Problem with ESP8266 Get Request and DMD2 Library

texts:
I am using ESP8266 to download information from server using simple get Request and DMD2 library to draw them on display.
Problem I have is, that when I call dmd.begin() after some time ESP8266 will become unable to connect to the server, sometimes it even causes watchdog resets wdt.
Without calling dmd.begin(), it gets the response every single time and doesn't reset.
Could you help me to fix it?


texts: How to get delay after millis and stop the relay

texts:
thats my flowchart for my code
    void loop()
{
  //-------------Fungsi Read sensor-----------
  sensorAll();

  hasilec = (ppmcensor - inputec);
  ph = (phcensor - inputph);

//  hasilec = random(-200, 0) / 100.0;
//  ph = random(-200, 200) / 100.0;

//  ph = -180/100.0;
//  hasilec = -1.2;

  unsigned long now = millis();

  Serial.print("pH    ");
  Serial.print(ph);
  Serial.print("  ");
  Serial.print("EC ");
  Serial.print(hasilec);
  Serial.println("");
  Serial.print(ph);  Serial.print(" ");
  Serial.print(hasilec);   Serial.print(" ");
  Serial.println(" ");

//  delay (500000);

  fuzzy->setInput(2, hasilec);
  fuzzy->setInput(1, ph);
  fuzzy->fuzzify();

  float pompa01 = fuzzy->defuzzify(1);//pHDOWN
  float pompa02 = fuzzy->defuzzify(2);//pHUP
  float pompa03 = fuzzy->defuzzify(3);//ABMIX

  Serial.println("Result= ");
  Serial.println("");
  Serial.print(" Pompa1 pHDOWN: ");
  Serial.println(pompa01);
  Serial.print(" pompa2 phUP  : ");
  Serial.println(pompa02);
  Serial.print(" pompa3 ABMIX : ");
  Serial.println(pompa03);
  Serial.println("");
  Serial.println("");
  Serial.println("");

  delay (2000);

  long int pompa1 = pompa01*1000;
  long int pompa2 = pompa02*1000;
  long int pompa3 = pompa03*1000;

  pump_periods[0] = pompa1; //PHdown
  pump_periods[1] = pompa2; //PHup
  pump_periods[2] = pompa3; //ABMIX

  for (int i = 0; i < jml_pump; i++) {
      if (now - pump_last_actuations[i] >= pump_periods[i]) {
          pump_states[i] = (pump_states[i] == LOW) ? HIGH : LOW;
          digitalWrite(pump_pins[i], pump_states[i]);
          pump_last_actuations[i] = now;
      }
  }

}

i now i cant use the delay and millis on the same time but how to get trick for thats code


texts:
I am new to Arduino and have tried all kinds of code for attempting to achieve this. None with any luck, however. I feel that it should be a relatively easy task and therefore, figured that someone out there with more proficiency with an Arduino than me, would be able to help.

Essentially, I have two commands sent to a device via the Leonardo serial port. One is the single character "R", and the other is the single character "O". The device then sends back 8 binary bytes (non ASCII) in floating point format per command. So if I send O, it will return 8 binary bytes, and then the same goes for if I sent R.

The commands O and R need to be simultaneously sent via the serial every 250ms and wait for their respective responses before sending the next command.

I also need to store the device's response to O and the device's response to R in respective variables that will have a new value every 250ms. I am not familiar with single point format and therefore am unaware of what variable system to use.

Here is my best, yet unsuccessful attempt:

unsigned long previousMillis = 0;
const long interval = 250;
int responseO;
int responseR;

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

    while(!Serial);
}

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

    if(currentMillis - previousMillis >= interval) { //timer for every 250ms
        previousMillis = currentMillis;
        Serial.println("R");               //Figured that "println" with a string for the character R should be ok

        if(Serial.available() > 0) {          //Don't know if I am correct here, I was hoping that the serial would only be read if the device responded to the command R
            responseR = Serial.read();       //Read serial for device's response to command R and save it in a variable
        }

        Serial.println("O");               //Do the same thing for the command O

        if(Serial.available() >0) {
          responseO = Serial.read();
          }
    }
}

However, whenever I test this, it appears that the program is unable to differentiate between which responses are due to one command, and treats one response as if both commands requested it when only one did. Also is a floating point format variable just a float?

Thank you so so much, I really need some help this has been burning away at me for days........

Cheers, Harry


texts: Does flashing ESP8266/ESP-01 firmware mean uploading a new 'sketch' and why different firmware?

texts:
Hi I am new to IOT and I am now in love with this. However I'm a little confused right now with the jargon. My question is similar to this. But I do have some extra questions though.

When using ESP as standalone microcontroller, and if I uploaded a sketch written on the Arduino IDE, does that count as 'Arduino firmware' other people are referring to?
On the Arduino IDE, uploading sketches onto the ESP8266 seems easy by just installing extra libraries from Board Manager and selecting the right board. Is this step equivalent of doing this but for different firmwares such as AT, NodeMCU and Micropython?
For the NodeMCU dev boards, is the default firmware on the module NodeMCU firmware? If I were to use the Arduino IDE to upload a sketch, does that mean I have overwritten the NodeMCU firmware with my custom 'Arduino firmware' sketch?
To the extent of my knowledge, when using NodeMCU firmware, I would need to code in LUA language using some sort of LUA IDE and if I flashed/uploaded micropython I would need to code in micropython using exclusively the Thonny IDE. And there is no way to code in micropy or LUA from the Arduino IDE.
Is the reason for using other firmware is because of how the code is compiled and the language used?

If someone could clear things up for me I would greatly appreciate it. Thanks!


texts: Do gyroscopes purposefully show erroneous data?

texts:
I tested an MPU-6050 (GY-521) using an Arduino Nano. I used the I2CDevLib and opened the MPU6050_DMP6.ino with the Arduino IDE. I opened the MPUTeapot.pde Processing-file with Processing. A few changes was necessary to make it work:

MPU6050 mpu;

was changed into:

MPU6050 mpu(0x68);

Additionally I commented out this line:

#define OUTPUT_READABLE_YAWPITCHROLL

and uncommented this line:

#define OUTPUT_TEAPOT

When turning everything on, the arrow (Processing) would turn with 5 degrees/s clockwise around the z-axis (plus a very small amount around the other two axes). After about 20 seconds, it would stop, and turn around the x-axis pretty fast for 3 seconds. Then it would stop. Now, the gyroscope+accelerometer would work perfectly. This happens every time I test it.

This happens only when the gyroscope is perfectly still on the ground. It does not stabilize if I move it around. Only after it is left completely still, it'll stabilize after 23 seconds.

Is this how it should work, or is it a problem with the gyroscope? Could it even be caused by the I2CDevLib? Can anybody else confirm this?


texts: Arduino Due analog output has 500mV offset

texts:
I use a simple serial connection to tell the Due what to output into an analog output pin. However, the outputs are offset about 550mV (as seen on an oscilloscope) and the maximum value of 255 gives ~2.7V. What am I missing? Why can't the DAC output 0V - 3.3V mapped onto 0 - 255 values?

int output = DAC1; // analog output pin
String inData;

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

void loop() {
  while (Serial.available() > 0) {
    char value = Serial.read();
    inData += value;
    if(value == '\n'){
      val = inData.toInt(); // 0..255
      analogWrite(output, val);
      Serial.println(val);
      inData = "";
    }
  }
}


texts:
Hello I want to program an Attiny13a with Arduino code. I always have this error  when I add repository "no file board.txt" in path.
How to successfully configure IDE to able burn on it?

I use :
Link 1
And :
Link 2
But nothing changed .

I am using IDE Arduino v1.6.7.

Finally I import ATTiny13 (link) now these errors appear:

Board attiny13:avr:attiny13 doesn't define a 'build.board'
preference.Auto-set to: AVR_ATTINY13

Board attiny13:avr:attiny13at4 doesn't define a 'build.board' preference. Auto-set to: AVR_ATTINY13AT4

Board attiny13:avr:attiny13at9 doesn't define a 'build.board' preference. Auto-set to: AVR_ATTINY13AT9

Warning: platform.txt from core 'Attiny13' contains deprecated compiler.path={runtime.ide.path}/hardware/tools/avr/bin/, automatically converted to compiler.path={runtime.tools.avr-gcc.path}/bin/. Consider upgrading this core.

Warning: platform.txt from core 'Attiny13' contains deprecated tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude, automatically converted to tools.avrdude.cmd.path={path}/bin/avrdude. Consider upgrading this core.

Warning: platform.txt from core 'Attiny13' contains deprecated tools.avrdude.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf, automatically converted to tools.avrdude.config.path={path}/etc/avrdude.conf. Consider upgrading this core.

Warning: platform.txt from core 'Attiny13' contains deprecated recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}", automatically converted to recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}". Consider upgrading this core.


texts:
I get the following error when I try to burn the arduino bootloader on an atmega328 mcu:

avrdude: verification error, first mismatch at byte 0x0000
         0xfd != 0x05

I am using an Arduino as ISP programmer. My computer runs Ubuntu 16.

This did not happen when I was using Ubuntu 14. I also tested it on another machine with Ubuntu 14 and this error does not appear. Seems to be something with Ubuntu 16. I installed Arduino IDE using the out of the box repo.

The avrdude command launched by the IDE is:

/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P/dev/ttyUSB0 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xde:m -Ulfuse:w:0xff:m

Am I safe replacing the -Uefuse:w:0x05:m with -Uefuse:w:0xfd:m ?? If answer is yes how can I get the IDE to do this correctly?

Uploading a sketch works pretty well.


texts: How do I connect an Adafruit headphone jack to an Arduino 101?

texts:
I just purchased Adafruit headphone jack and I want to know how to connect it to an Arduino 101. I'm trying to use a breadboard to play a sample tone melody from the Arduino libraries, which I want to hear with my iPhone headphones.

I have been looking online for instructions on how to do this, but found nothing. Please advise.

Thank you!


texts: What would be the right way to connect 2 fsr resistors, jumper wire cables and 2 10khm resistors onto the breadboard

texts:
Hi at the moment we are trying to connect 2 fsr sensors to the breadboard and then using the jumper wire cables to connect it from the breadboard to the arduino device.

we connecting the cables to 2 analog pins and the other two to the 5v and ground pin, the problem is that they way we phyically connect these components on both the breadboard and the ardiuno are wrong.
So could someone help me to understand what would be the right way to physically connect all the components together.


texts:
Can I use two interrupts on to count rpm square signals coming from two hall effect sensor modules (that has built in comparators to generate square signals) ?

What if two signals come together ? Will they conflict with each other ?

Will this work on attiny85 ?

I used to use two interrupt to read encoders where the two signals never conflict with each other

Thank you in advance


texts: ESP8266 print DNS address (obtained via DHCP)

texts:
I've set up an ESP8266 (Wemos D1 Mini) to get IP-information via DHCP.
Everything works fine and I can print the information :

Serial.print(WiFi.macAddress());
Serial.print(WiFI.localIP());
Serial.print(WiFi.subnetMask());
Serial.print(WiFi.gateway.IP());

But how do I print the DNS-address ??

I cant find a function for this ???

/Kind regards : Gurra


texts: Controlling fluid flow with ball valve and flow control using arduino

texts:
I am pondering on a project to do the following :
I want to control fluid rate using a ball valve and servo/stepper motor
I have a flow rate sensor that can give me a flow value.
I want to use a 1602 keypad LCD shield to be able to specify the rate of flow, and the valve will keep it there.
I need to dose my water system with chemicals at a specific rate and as the tank gets empty the rate needs to be able to be adjusted by the stepper/servo/ball valve to keep to the specified lt/hour rate.
Please can somebody assist in the coding to make this work.
I have the following hardware :
Arduino Uno R3
1602 keypad lcd shield
stepper motor
stepper motor controller
flow rate sensor 0-30lt/min
I can hook al these together on instruction but I battle to figure out the code.
Thanks,
G


texts:
I’m working on a project, to create an air mouse for people with repetitive strain injury (since I have it as well). I’m flexible with the hardware required. The plan is to use data from an IMU for movement. I’m currently learning how to work with the sensor.
I have also been researching how to eventually convert the sensor data to mouse movements. I understand that you can do this over Bluetooth (Bluetooth HID, or HID over GATT). However, this is where I reach my limits.
I was hoping to find a library, which can do this for me (similar to the mouse.h library) as it feels like it would take me months learning about the Bluetooth standards to try to implement it myself.
The options I found in my research:

Adafruit boards only library so ties you to their ecosystem
mbedOS library, code seems different then the arduino sketches I’ve
seen so far and is difficult to understand
esp32 based library,    would need to learn how to use that
processor and not sure if    supported properly in arduino IDE)
Arduinoble.h library, would    you need to create the mouse HID
profile from the ground up)

Since many of you are much more experienced than me, I would be grateful for any guidance on how to proceed. Would you show a preference for any of the options above? Or should I be attempting to do things differently, e.g. without a mouse library (but where would I start)?
PS. In case it’s useful, I have basic familiarity with C++ (e.g. I understand classes, pointers, etc.), but I don’t have a programming background. I have done a few simple arduino projects and most of the examples on the official website.


texts: How do I connect this SPI serial display to an Arduino?

texts:
I've recently purchased a screen on DX without really thinking about it, because I have no idea how to connect it to my Arduino.

It is this screen:

The description says that it uses the SPI serial protocol but I don't know how to connect that ribbon to my Arduino, is soldering cables to it the only way?


texts:
I have two DS18B20 temperature sensors connected via a OneWire bus to an arduino. I noticed that these sensors get hot, when permanently powered and decided to just turn them on for measurment.

First attempt: Define a pin as output and feed the sensors. Because I received only one value (first sensor on bus), I assumed that the current delivered may not be high enough and utilized a transistor (+resistor) as switch for the main 5V line to feed the sensors from the mains (as before). The result is the same. I only get the value of the first sensor. When I connect the sensors directly, I get both values.

I tried up to 4 seconds delay after switching the bus on and again after reading the values (before switching the bus off again), with no luck. Only the first sensor answers.

Do I have a timing or a current problem here?

UPDATE

Wiring (working): Two DS18B20 in parrallel with a 4,7k resisor between DATA and VIN. One Arduino pin used, Sensors directly powered by power-supply (same as arduino)

Wiring (not working): Broke the VIN line and added a transistor as switch between power-supply and sensors VIN. Used a second pin and a resistor to power up the line.

The transistor is a TC124E (npn) logic level transistor. I have the feeling, that this boy is not providing enough current to the sensors, which in addidtion have five meter cables attached...

UPDATE II
It is not the current. I replaced the transistor with a mosfet (70T03H) and the result is exactly the same: When switched, only one sensor answers . When I connect the gate directly to a +5V line, I get both values as expected.

Kinda think, that the switching of the pin irritates the bus or the specific device.

UPDATE III (Solution)

I tracked this down to a mixture of

Different resolution settings on the sensors
my code not waiting long enough to get the sensor with the higher resolution to setup (on-to-read time). Giving the bus slightly more time to setup before any reading is accepted, solved my problem.


texts: Can I use an internal clock on Wemos D1 Mini?

texts:
I have a working Wemos D1 Mini setup measuring temperature and sending it over wifi to my server. Now I'm using a battery powered unit, and playing around with power consumption optimization and how to reduce it.
One thing I need is time (current, either epoch or DST) - so I implemented NTP, but everytime my ESP is waking up after deep-sleep, it needs to reconnect to wifi, gather time, measure temperature, send results.
This pdf states that ESP8266 has an internal clock. I'm having troubles finding anything beside "RTC shields on Wemos/Arduino" or "NTP on ESP8266" on the internet about something that is like an internal clock. There must be something, because otherwise it could not work (my understanding about clock and hardware is limited by now).
My question is: can I use NTP to update my internal clock, using it for some minutes (I think it will drift after some minutes), updating via NTP once in a while - to simply reduce network traffic and still use deep-sleep mode?
Any hints are welcome!


texts: Warm Atmega328p and weird power behaviour

texts: I recently built a circuit with an atmega328p (which I have never used before standalone) and attached all the neccessary components (crystal, capacitors etc). However, when I powered it up with a regulated 5v input, I noticed the chip getting a little bit warm. Not hot, the temperature seems quite constant, and everything still works just fine. Another strange thing though, is when I connect the VCC to AVCC together as specified in the datasheet, the circuit doesn't work at all: The LCD screen just shows solid blocks at the top. When I disconnect the wire again, everything is back to normal. What went wrong? It is perfectly possible that there is a small solder bridge on my perfboard.


texts: Quadrature Encoder:Interrupts: Reset Count

texts:
I'm working on a quadrature encoder(with a 500ppr codewheel) with a Channel A, B and an Index pulse output.  Using an Arduino Mega I'm counting the number of pulses on Channel A on the rising edge. The code for counting pulses on channel A using an interrupt is straight forward enough with plenty of sources and examples out there to work with.

I've used the the code below to the count the pulses(in an increasing manner). What I'm trying to figure out is how I can reset the overall count using a second interrupt. The second interrupt is invoked when the Index channel pulses high.So in another words when the index channel pulses to indicate a full rotation on the code wheel the main count will reset to zero

#define CHA 2
#define CHB 3
#define CHI 19

volatile int count = 0;
volatile byte INTFLAG1 = 0;

void setup()
{
  pinMode(CHA, INPUT);
  pinMode(CHB, INPUT);
  pinMode(CHI,INPUT);

  Serial.begin(9600);
  Serial.println(count);

  attachInterrupt(0, flag, RISING);

 }

void loop()
   {

       if (INTFLAG1)
             {
               Serial.println(count);
               INTFLAG1 = 0; // clear flag
             }

    }

void flag()
    {
       INTFLAG1 = 1;
       if (digitalRead(CHA) && !digitalRead(CHB))
               {
                count++ ;
               }
     }

Is it possible to implement the reset of the main pulse count with a second interrupt as described?

From what I've read interrupts work at the same level of priority- so I'm thinking there might be a problem here to implement this approach as the interrupts would have to be nested

Any help is appreciated if anyone has done anything like this using interrupts or can point me in  the right direction.


texts:
I made an program so if I turn on my rotary encoder the position and the rotation comes on a LCD screen. But I need to change it a bit up for my teacher, she wants to see the graph of the pulses on the serial monitor. I searched it up and can't find a solution? Any help?

My program:

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#define outputA 2
#define outputB 4
int counter = 0;
int angle = 0;
int aState;
int aLastState;
int lastAngle = 0;
String rotationDirection;
String savedRotationDirection;

void setup() {
  pinMode (outputA,INPUT);
  pinMode (outputB,INPUT);

  aLastState = digitalRead(outputA);
  lcd.begin();

     }

void loop() {
  aState = digitalRead(outputA);
  if (aState != aLastState){
     if (digitalRead(outputB) != aState) {
       counter ++;
       angle ++;
     }
     else {
       counter--;
       angle --;
     }
     if (counter >=30 ) {
      counter = 0;
     }

     if (angle < lastAngle){
      rotationDirection = "CCW";
     }
     else {
      if (angle > lastAngle){
        rotationDirection = "CW";
      }
      else {
        rotationDirection = savedRotationDirection;
      }
     }
     lcd.clear();
     lcd.setCursor(0,0);
     lcd.print("Position: ");
     lcd.print(int(angle)*(-1));
     lcd.print((char)223);
     lcd.setCursor(0,1);
     lcd.print("Rotation: ");
     lcd.print(rotationDirection);
     savedRotationDirection = rotationDirection;
     lastAngle = angle;
  }
  aLastState = aState;

}


texts: No code, but Fatal exception (0): epc1=0x402066ac, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000 in Serial Monitor

texts:
I have a Wemos d1 mini, and when I upload nothing or anything to it, the built-in LED always lights up and the serial monitor gets a lot of garbage at every baudrate.  I have supplied it with 4 AA batteries and the board has a built in voltage regulator of 3.3V at the 5V pin.

The Wemos d1 mini contains the esp8266 chip.

Please help me!  I have searched everywhere.  This just happened all of a sudden, the board was working perfectly fine before too.


texts: Not able to upload any code to Arduino Uno

texts:
NOTE: Using the Arduino Uno

I am WORKING on a project that I have to submit in a few days. My arduino was all set up and was working fine.

Project:Arduino controls a 9v motor depending on the command given. As the arduino only provides 5v , i added a 9v battery to it through a transistor

I decided to add new code into the arduino but when I tried it failed. I have uploaded code thousands of times before (successfully) all of a sudden the IDE keeps giving the following message

  avrdude: ser_open(): can't open device "\.\COM3": Access is denied.

I have looked up for a lot of solutions on this forum and elsewhere. Here are the things I have tried so far:

Changing the COM port
Disabling all the other devices CONNECTED to COM
Tightening the CONNECTIONS
Re installing all the drivers and the IDE
Rebooting the system
Using another laptop to upload code

All the above have given me the same output for some reason. The built in LED light and the power LED switch on when the board is CONNECTED to a power source (my laptop). Could the board have been damaged by any chance ? How can I check if the board is spoilt ? Should I buy a new board ?


texts: Sending mouseX and mouseY from Processing to Arduino

texts:
I'm new to serial communication and trying to send mouseX and mouseY from Processing to Arduino. Serial monitor doesn't show anything.

Processing code:

import processing.serial.*;
Serial port;
void setup() {
  size(500,300);
  port = new Serial(this , Serial.list()[0], 9600);
}

void draw() {
   text("X Y mouse",250,50);
   if (port.available() > 0) {
    port.write(str(mouseX)+' '+str(mouseY));
   }
}

Arduino code:

int x = 0;
void setup() {
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0) {
    x = Serial.read();
    Serial.print("I received: ");
    Serial.println(x);
  }
}

when I close Processing window and enter "ok" in Arduino serial monitor I see:


texts:
I am trying to blink two LED's, starting at slow rate then increasing to fast s follows: 1 on, 1&2 on, 2 on, 1&2 on, 1 on, etc. The blinks go through the loop twice then speed up and repeat until both are on continuously. Then I want LED's 3 & 4 to come on.
I got the 1 & 2 LED's to blink as I want but anything I put following my for / if loop goes into the loop.
This works for blinking the 1 & 2 LED's:

int led1 = 9;
int led2 = 10;
int led3 = 11;
int led4 = 12;
int delay1 = 700;
int delayAmount1 = delay1 / 10;

void setup() {

pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}

void loop() {{
delay1 = delay1 - delayAmount1;

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

if (delay1 > 10)

digitalWrite(led1, HIGH); //yellow on (yellow)

delay(delay1);

digitalWrite(led2, HIGH); //red and yellow on (orange)

delay(delay1);

digitalWrite(led1, LOW); //yellow off (red)

delay(delay1);

digitalWrite(led1, HIGH); //yellow on (orange)

delay(delay1);

digitalWrite(led2, LOW); //red off (yellow)

digitalWrite (led1, LOW); //yellow off (all off)

}
}

// digitalWrite(led3, HIGH); //blue on

//delay(1000);

//digitalWrite(led4, HIGH); //green on

}

If I remove the // from

// digitalWrite(led3, HIGH); //blue on
//delay(1000);
//digitalWrite(led4, HIGH); //green on

they become part of the loop. Can someone tell me what I am doing wrong? Kind of new to this.


texts: How to use the ESP32 WROOM GPIOS above #18 with arudino ide?

texts:
I am using the Arduino IDE version 1.8.8 I am trying to control an ESP32-wroom. The gpios for pins 16 and 17 are working. I have some relays on GPIO's 18 and 19 that I'd also like to be able to control. I also have no control over GPIO's that are over 17 I've tried 18 through 27 and I can't toggle them.

#define relayPin3 18
#define relayPin4 19

int relayflag = 0;
void loop() {
  delay(1000);
  if (relayflag == 0){
    digitalWrite(relayPin3, LOW);
    digitalWrite(relayPin4, HIGH);
    relayflag =1;
  }
  else
  {
    digitalWrite(relayPin3, HIGH);
    digitalWrite(relayPin4, LOW);
    relayflag = 0;
  }

}

I noticed that GPIO's 18 and 19 are also shared with spi ports.

Does the digitalWrite command work for any GPIO or is it in use by another library? Is there some other command to get access to the GPIO's I need to use? Some library I need to modify.


texts: Wiring light sensor OPB704WZ to Arduino Due

texts:
I would like to create a tachometer with the light sensor OPB704WZ.

I followed this schema https://tonyrobotdt081.wordpress.com/2014/04/10/report-on-the-light-sensor-opb704wz/ on a bread board (for now), and tried to measure the voltage difference on the signal pin (green on the schema).

Problem is, I don't see a clear difference between a white surface and a black one; It does change if I put the sensor closer or further away, but that's about all I can see.

Is there something else I need to add to my wiring to make the difference between high and low depending on the luminosity more obvious? I know others have been able to use this sensor for the same purpose.


texts:
I am struggling to choose servo motor for my project. There are two servos on ebay. Th First one is named Only "Towerpro micro 9g servo" and the second one that is cheaper is named as a "Towerpro 9g Digital servo".
The Links are:

Servo1: http://www.ebay.in/itm/TowerPro-SG90-9g-Mini-Servo-9-gram-Servo-RC-Robotics-/201386256243?hash=item2ee38e6773

Servo2: http://www.ebay.in/itm/251928442829?aff_source=Sok-Goog

My Problem is that I am confused with the name "Digital Servo". Its cheaper but I a afraid that will it work as normal.
Please help me.

Are both the same product, but with a different name?


texts:
How do I format an arduino String when I do not want to print it?
I know that one can use printf() or other methods to print a formated string and unfortunately that's all I find with google.
But that's explicitly not what I'm looking for, I want to assign the formated string to a variable instead.
There are itoa, etc. which I could use, but if there is a standard function to use like String a=format("an integer: %i",myinteger); I would really prefer this one.


texts: How can I measure maximum range of my ohm meter?

texts:
Hello everyone I am working on a project that will measure ohm value of a resistor .
Schematic / article link
https://create.arduino.cc/projecthub/iasonas-christoulakis/how-to-make-an-arduino-ohm-meter-90fda8
And
Here is the code below
int analogPin= 0;
int raw= 0;
int Vin= 5;
float Vout= 0;
float R1= 1000;
float R2= 0;
float buffer= 0;

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

 void loop()
{
raw= analogRead(analogPin);
if(raw)
{
buffer= raw * Vin;
Vout= (buffer)/1024.0;
buffer= (Vin/Vout) -1;
R2= R1 * buffer;
Serial.print("Vout: ");
Serial.println(Vout);
Serial.print("R2: ");
Serial.println(R2);
delay(1000);
}
}

There need to be a known and another unknown resistor.
The ohm value of known resistor is supposed to be 1k ohm
So my question is, what is the max ohm range will my arduino ohm meter will be able to measure of the unknown resistor with 1k reference resistor and how to calculate it?
5 - 10% accuracy is enough for me
Thanks for giving me your attention :D


texts:
I need to measure around 50 - 100 analog sensors (resistors). This poses two challenges:

Arduino has fewer analog pins. I'm targeting something small like arduino Mini or Nano, which can have up to 8 analog pins. The solution for this could be several multiplexors like this one. Is there a better option? Is this the best way to read so many analog sensors with Arduino? I am thinking also in several arduino mini talking through wifi / bluetooth with the main one which would also aid with Problem #2.
There would be a lot of cables for this setup, and I need to keep it all as flat and flexible as possible. So I was thinking of some kind of adesive copper conductor, paper printed circuit or plastic. The thing is that it would become difficult to create if I do it myself. What would be the easiest way to achieve a multi-track, flexible circuit for substituing Arduino cables?


texts: Ultrasonic Flowmeter Using TDC-GP22 and Arduino Uno

texts:
I'm working on a project of Ultrasonic Flow Meter with TDC-GP22 using Arduino UNO. I used the library of leokoppel

In my code,the configurations of the registers are copied from the Application Note of GP22, from page 22 to page 25. I didn't use the temperature sensor so I jumped those steps related to that. No calibration neither. I just want to get some results of time of flight to be able to calculate the distance between two sensors for now.

My code for test:

#include "GP22.h"
#include <SPI.h>
#include <avr/io.h>

/*
 *
 * Test setup (Arduino Uno, through 5->3.3V level shift)

 *     10 -> SS
 *     11 -> MOSI
 *     12 -> MISO
 *     13 -> SCK
 *     2  -> INT
 *     5V -> VCC
 *     GND -> GND
 *     4 -> DS18B20 temperature sensor (optional)
 */

const bool DEBUG = 1;
const int FAST_MODE = 1;
const int PIN_INT = 2;

GP22 tdc(PIN_INT, DEBUG);

float cycleFactor_ns = 0;

void setup() {

  Serial.begin(115200);
  Serial.println("Go !");

  tdc.init();

  tdc.writeRegister(0, 0x430BE800);
  tdc.writeRegister(1, 0x21444000);
  tdc.writeRegister(2, 0xA0138800);
  tdc.writeRegister(3, 0xD0A24800);
  tdc.writeRegister(4, 0x10004000);
  tdc.writeRegister(5, 0x40000000);
  tdc.writeRegister(6, 0xC0C06100);

  tdc.printConfigRegisters();

  byte a = tdc.readRegister(READ_REG_1);

  Serial.println(a,HEX);
  Serial.println("Test communication: ");
  Serial.print(tdc.testCommunication());
 }

void loop() {

  tdc.sendOpcode(OPCODE_INIT);
  tdc.sendOpcode(OPCODE_START_TOF_RESTART);
  tdc.waitForInterrupt(10000000);

  delay(20);

  Serial.println(tdc.readRegister(READ_RES_3),HEX);
}

From oscilloscope I got the right number of fire pulses(20) with right frequency(1MHz):
Signal (the blue one is the signal of transmitter before amplification, green one is after amplification, yellow one is the signal of receiver)

But what I got from the code:

Go !

attached pinChangeISR_debug

Register 0: 0x430be800

Register 1: 0x21444000

Register 2: 0xa0138800

Register 3: 0xd0a24800

Register 4: 0x10004000

Register 5: 0x40000000

Register 6: 0xc0c06100

21

Test communication:

\/Test took 180 us

1

69978000

69978000

69978000

69978000

69978000

69978000

69978000

...

21 is the first byte of register 1, and 1 is the result of testcommunication(). These two means the test of communication is successful. But the results of reading RES_3 are always the same, and the  waitForInterrupt() doesn't work(maybe the code shouldn't be written like this) -- Timeout all the time.

What I expect, of course, is the result can change each time it measures.(impossible to get exactly the same measurement of ToF all the time)

Any help appreciated!


texts: Is it possible to use ESP8266 modules interchangeably?

texts:
I discovered that there are multiple types & versions of ESP8266 modules.

I'm wondering:

Build my application around one type (eg ESP-03) and in future swap the module with another (ESP-07), continuing to use the same library and code?

Given the lack of information online, I couldn't find an answer for this online.


texts: I have this arduino motor shield, and I want to connect a Bluetooth module, but don't know how (the tx and rx pins are used by the plate). Tried to sold it but now I don't have the tin to do it. So I want to know if I can use this holes (don't know their names) "the ones encircled in red" to connect the Bluetooth module. Thank you folks.


texts:
How do I move more than 128 pixels when using Arduino Leonardo's Mouse.move?
Is it possible to modify the header file or use a different library?
I used the MouseTo library, but it wasn't the move I wanted.
We want to move as fast as possible to the relative coordinates, not as one pixel.
I've searched almost every community, but I haven't.
Give them a hand.


texts: Adapt a differently pin-interspaced chip to be used with an Arduino

texts:
Happy new year to everyone!

This is how my chip looks like:

Those numbers are millimeters. Both the pin spacing and pin width are different from what Arduino uses.

Is there any quick (or less quick) and reliable way to connect this chip to an Arduino Uno ?


texts: can I check if why my motor isn't working?

texts:
I am currently using the arduino Uno connected with L298N(green pcb) connected to a dc motor rated 12V. I provided dedicated 12v power supply to the dc motor and the arduino board's power is supplied by usb connected to my pc. I connected Pin 9 of arduino uno to 'ENA' on L298N , Pin 7 & 8 (UNO) to 'INA' & 'INB' of L298N. Connected '-' polarity of Motor power supply to GND of L298N, while also connecting the 'GND' of L298N to the GND of Arduino UNO. Last but not least, connecting the 'OUT B'to the dc motor. This is the picture of how L298N(green) look like https://sea.banggood.com/Green-Board-L298N-DC-Motor-Driver-Board-Stepper-Motor-p-974549.html?cur_warehouse=CN

Can i check why my motor isn't running? Thanks in advance.

char data = 0;
int enB = 9;
int InC = 8;
int InD = 7;

void setup()
{
    Serial.begin(9600);
    Serial.println("Motor test !");
  pinMode(enB, OUTPUT);
   pinMode(InC, OUTPUT);
  pinMode(InD, OUTPUT);

}

void loop()
{Serial.println("Entered loop, should start moving now !");
  digitalWrite(InC, HIGH);
  digitalWrite(InD, LOW);
   digitalWrite(enB, HIGH);
   analogWrite(enB, 255);
 }


texts:
In my last question I got the suggestion to get a voltage regulator to power my ESP8266, so I went out to buy one and in the end my ESP8266 turned on. Then I started wiring the Tx/Rx pins through the Logic Level Shifter and tried out this piece of code I found online

// Basic serial communication with ESP8266
// Uses serial monitor for communication with ESP8266
//
//  Pins
//  Arduino pin 2 (RX) to ESP8266 TX
//  Arduino pin 3 to voltage divider then to ESP8266 RX
//  Connect GND from the Arduiono to GND on the ESP8266
//  Pull ESP8266 CH_PD HIGH
//
// When a command is entered in to the serial monitor on the computer
// the Arduino will relay it to the ESP8266
//

#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX

void setup()
{
    Serial.begin(115200);     // communication with the host computer
    //while (!Serial)   { ; }

    // Start the software serial for communication with the ESP8266
    ESPserial.begin(115200);

    Serial.println("");
    Serial.println("Remember to to set Both NL & CR in the serial monitor.");
    Serial.println("Ready");
    Serial.println("");
}

void loop()
{
    // listen for communication from the ESP8266 and then write it to the serial monitor
    if ( ESPserial.available() )   {  Serial.write( ESPserial.read() );  }

    // listen for user input and send it to the ESP8266
    if ( Serial.available() )       {  ESPserial.write( Serial.read() );  }
}

But I when I tried sending "AT" to the ESP via the Serial Monitor nothing happend.

This is my current wiring, I hope it's not to unclear:

Hopefully someone can help me :)


texts:
I have a dipswitch of 4 steps to get a binary number that will turn out to decimal from 0 to 15, So I need to get that number and make it the ammount of minutes to make something and also be aware of some input while the time runs out.

So I was thinking of having a variable being equal to millis() and then dividing it by 60,000 which is a minute in millis and If I get an integer that must mean a minute has passed, the problem is that I don't know how to check if the result is an integer or a float.

any advice?


texts: Simple GET request with ESP8266HTTPClient

texts:
I am trying to do a simple GET request. But I always get status code -1. Here is my complete code.

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

WiFiClient client;
#define AP_SSID "CCR"
#define AP_PASSWORD  "ccrxxxxx"

void wifiConnect() {
  Serial.print("Connecting to AP");
  WiFi.begin(AP_SSID, AP_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
}

void setup() {
  Serial.begin(9600);
  pinMode(0,1);
  Serial.begin(9600);
  delay(300);
  Serial.println("starting");
  WiFi.disconnect();
  Serial.println("disconnected");
  wifiConnect();
  Serial.println("Connected");
}

void loop() {
  HTTPClient http;
  http.begin("https://calm-falls-41696.herokuapp.com/api/v1/cards");
  http.addHeader("Content-Type", "application/json");
  int httpCode = http.GET();
  Serial.println(httpCode);
  if(httpCode == HTTP_CODE_OK) {
  Serial.print("HTTP response code ");
    Serial.println(httpCode);
    String response = http.getString();
    Serial.println(response);
  }
  http.end();
}

Wifi connection was successful. But in my serial terminal I always see -1. I am using PlatfromIO in Visual Studio code.

Update 1: The URL was corrected.

 http.begin("https://calm-falls-41696.herokuapp.com/api/v1/cards.json");

I tested it with google.com too. But it is still returning -1.


texts:
My understanding of the H-bridge is, that activating in1 or in2 will direct the 12V current to the motor, so it either spins right/left. Not that in1 or in2 is the actual current passing through to the 12V motor.

These are the schematics.

I am trying to activate the H-bridge and the 12V motor by powering In1 with digital 2 from my Arduino.

The power outlet is an universal adapter connected to my wall outlet, which then goes to a breadboard power supply.

I don't have a functioning multimeter, so I cannot measure the exact current going through, but I do know, that if I place in1 in the power outlet's Vout the 12V motor spins.

Other than that, I do not have much information, and I would like to ask you guys for help as to why, the 12V motor doesn't spin when I power in1?


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

#define SSID "name-of-my-network" //replace XXXXX by your router SSID
#define PASS "password-of-network" //replace YYYYY by your router password
#define IP "184.106.153.149" //thingspeak.com IP

const int tempPin = A0; //configure Arduino pins
String GET = "GET /update?key=thingspeak-api-key&field1=";
SoftwareSerial mySerial(10,11); //Serial communication to ESP8266 module(RX, TX)
unsigned long starttime;
unsigned long sampletime_ms = 30000;
unsigned long delay_time = 60000;

void setup() {
  Serial.begin(57600);
  while(!Serial) {
    ;
  }
  mySerial.begin(115200);
  Serial.println("Initializing...");
  //communication with wifi module
  mySerial.flush();
  mySerial.println("AT");
  delay(2000);
  if(mySerial.find("OK")) {
     Serial.println("Communication with ESP8266 module: OK");
   } else {
     Serial.println("ESP8266 module ERROR");
   }
   connectWiFi();
   //initialize timer
   starttime = millis();
}

void loop() {
  // put your main code here, to run repeatedly:
  if ((millis() - starttime) >= sampletime_ms) {
    char buffer[10];
    int analogReading = analogRead(tempPin);
    String temperatureStr = dtostrf(analogReading, 4, 1, buffer);
    temperatureStr.replace(" ","");
    updateSensors(temperatureStr);
    //wait next sampling cycle
    Serial.print("Wait ");
    Serial.print(delay_time/1000);
    Serial.println("s for next sampling");
    Serial.println();
    delay(delay_time);
    //initialize new cycle
    Serial.println();
    Serial.print("Sampling (");
    Serial.print(sampletime_ms/1000);
    Serial.println("s)...");
    starttime = millis();
  }
}

void updateSensors(String tempStr){
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  mySerial.println(cmd);
  delay(2000);
  cmd = GET;
  cmd += tempStr;
  cmd += "\r\n";
  delay(1000);
  int strsize = cmd.length();
  mySerial.println("AT+CIPSEND=" + String(strsize));
  delay(2000);
  mySerial.print(cmd);
  if(mySerial.find("OK")) {
    Serial.println("Transmission completed with success");
  } else {
    Serial.println("Transmission failed!");
  }
}

boolean connectWiFi(){
  Serial.println("Connecting wi-fi...");
  String cmd ="AT+CWMODE=1";
  mySerial.println(cmd);
  delay(2000);
  mySerial.flush(); //clear buffer
  cmd="AT+CWJAP=\"";
  cmd+=SSID;
  cmd+="\",\"";
  cmd+=PASS;
  cmd+="\"";
  mySerial.println(cmd);
  delay(5000);
  if(mySerial.find("OK")) {
    Serial.println("Connection succeeded!");
    return true;
  } else {
    Serial.println("Connection failed!");
    return false;
  }
  Serial.println();
}

I am using the above code and have connected the ESP8266 to the Arduino as follows:

  TX of ESP8266 to pin number 11 of Arduino
  Rx of ESP8266 to pin number 10 of Arduino
  Vcc of ESP8266 to 3.3V power supply taken from Arduino
  GND of ESP8266 to GND taken from Arduino
  CH_PD of ESP8266 to GND

It seems that I can't get the ESP8266 working. Could anyone could help me? I would really appreciate any help since I cannot continue my project.


texts: ATTiny85 USB Troubleshooting. Device is not recognized when programmer asks to plug in device

texts:
I have bought this cheap AVR Programmer Board and I thougth that I would be OK just plugging it into my USB port. Then after I did that nothing happened so I passed last 4 hours trying to understand what was going wrong. I learned that ATTiny85 microchips often come with no bootloader.

So first I tested it with Arduino as ISP and simple blink code. It worked. Then I downloaded micronucleus and i flashed it via Arduino as ISP. I think this process worked pretty well as the output show
> avrdude -C ../etc/avrdude.conf -c arduino -p t85 -P COM3 -b 19200 -U flash:w:/micronucleus/firmware/releases/t85_default.hex

 avrdude: AVR device initialized and ready to accept instructions

 Reading | ################################################## | 100%
 0.01s

 avrdude: Device signature = 0x1e930b (probably t85) avrdude: NOTE:
 "flash" memory has been specified, an erase cycle will be performed
          To disable this feature, specify the -D option. avrdude: erasing chip avrdude: reading input file
 "/micronucleus/firmware/releases/t85_default.hex" avrdude: input file
 /micronucleus/firmware/releases/t85_default.hex auto detected as Intel
 Hex avrdude: writing flash (8166 bytes):

 Writing | ################################################## | 100%
 0.09s

 avrdude: 8166 bytes of flash written avrdude: verifying flash memory
 against /micronucleus/firmware/releases/t85_default.hex: avrdude: load
 data flash data from input file
 /micronucleus/firmware/releases/t85_default.hex: avrdude: input file
 /micronucleus/firmware/releases/t85_default.hex auto detected as Intel
 Hex avrdude: input file
 /micronucleus/firmware/releases/t85_default.hex contains 8166 bytes
 avrdude: reading on-chip flash data:

 Reading | ################################################## | 100%
 0.09s

 avrdude: verifying ... avrdude: 8166 bytes of flash verified

 avrdude: safemode: Fuses OK (E:FF, H:DF, L:62)

 avrdude done.  Thank you.

Problem that I'm now facing is that when I try to upload a code using ATTiny Development Board via arduino IDE (selecting Attiny85 digispark default 16.5mhz) and it asks me to plug in the device, device is not recognized.
I already installed drivers downloaded from github release section of DevicestumpArduino repository, tried installing micronucleus configuration driver via zadiag like i read in this question but nothing worked.
What am I missing?


texts: Serial.parseInt() takes longer time than desired

texts:
My whole code for master. Please head to void read() where I've used parseInt()

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

RF24 radio(7, 8); //Set up nRF24L01 on CE pin and CSN pin respectively

const uint64_t pipe = 0x0ABCDEF; //Address for communication between master and slave
uint16_t data[7];
const uint16_t buffer_size = sizeof(data); //Size of the payload for the RF
int i, flag;
int tx_counter = 0;

void read();
void setup() {

  Serial.begin(115200);

  radio.begin();
  radio.setChannel(2);
  radio.setDataRate(RF24_1MBPS);
  radio.setPALevel(RF24_PA_MIN);
  //radio.powerUp();
  radio.openWritingPipe(pipe);
  //radio.setPayloadSize(7);
  radio.stopListening();

  //Default values range from 100 to 700
  for (i = 0; i < 7; i++) {
    data[i] = 100 + (100 * i);
  }
  flag = 0;
  Serial.println("Enter 7 values");
}

void loop() {

  read();

  if (flag) {
    bool tx_ok = radio.write(data, buffer_size);
    tx_counter++;
    Serial.print("Transmission count:\t");
    Serial.println(tx_counter);
    print();
    if (tx_ok) {
      Serial.println("Transmitted Successfully");
      Serial.println("\nEnter Next set of 7 numbers");
    }
    else Serial.println("Transmission failed");

  }
}

void print() {
  for (i = 0; i < 7; i++) {
    Serial.println(data[i]);
  }
  flag = 0;
}

void read() {
  while (Serial.available()) {
    for (i = 0; i < 7; i++) {
      data[i] = Serial.parseInt();
    }
    flag = 1;
  }
}

My problem is that Serial.parseInt() takes some time. The code prints out the values to the serial monitor after sometime. I have timed it and it appears to be around 7 seconds. The arduino page on the function says default timeout is 1 sec. So I think 7 elements in the array takes 1 sec each. If I use Serial.setTimeout(2000), the same thing takes 14 seconds.

This has got to have a simpler way. I want it to behave like when we use Serial.read. Please help me on this.


texts:
I'm trying to receive remote information with an IR receiver and this is my code:

#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}

I tried to upload this to Arduino and it says:

exit status 1
redefinition of 'int RECV_PIN'

How can I fix this?


texts: Advanced ADC setup on Due (SAM3X8E) to increase precision

texts:
I want to make some precise measurements with Arduino Due. Although I'm using very good external voltage reference (LTC6655) measured data is still jumping around, especially significant when I'm trying to measure low voltages (0.1-0.05V). Can I improve ADC accuracy by changing it's settings?

The default Arduino Due ADC settings are:

// Initialize Analog Controller
pmc_enable_periph_clk(ID_ADC);
adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST);
adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1);
adc_configure_trigger(ADC, ADC_TRIG_SW, 0); // Disable hardware trigger.
adc_disable_interrupt(ADC, 0xFFFFFFFF); // Disable all ADC interrupts.
adc_disable_all_channel(ADC);

So, with adc_init we can configure frequency and startup time. And with adc_configure_timing we configure tracking time, settling time and transfer time. But how to select those values? Does increasing of that times improves precision?

Useful links:

Datasheet - ADC description starts on page 1317.

Atmel Software Framework - see adc.h and adc.c.


texts:
I am new to Arduino and although I am starting with and creating some basic projects my end goal right now is to be able to turn my Sonoff on and off via a momentary switch attached to my Wifi enabled Arduino board (Particle Photon). I'm not looking for the code I would just like to pointed in the right direction.

I flashed my Sonoff so that it now runs ESPEasy and set it up so that I can control it from my browser using http://10.0.1.35/control?cmd=event,TurnOn to turn it on and http://10.0.1.35/control?cmd=event,TurnOff to turn it off. I have been reading about using POST or GET requests but none of the examples I find seem to send a similar command to how I currently have my Sonoff set up.

My question is what should I be looking at and reading about to be able to send these types of commands via the Arduino?

Any recommendations are greatly appreciated. I'm thoroughly enjoying getting into coding but finding this step quite challenging to say the least!

Thanks!


texts: Serial connection two devices two power supplies

texts:
I'm trying to connect an ESP32-CAM to a 3d printer using a serial connection.
When powering the ESP from the 5V rail on the 3D printer(and using 3.3V zener diodes between tx, rx & gnd), everything works fine. The ESP expects 3.3V on the serial pins, hence the diodes.

circuit diagram

Common ground not shown.

Then when I try to run the ESP32 from its own 5v power supply, I cannot establish a serial connection, regardless of whether I connect the gnd from the 5v from the 3d printer with that of the ESP power supply.
In fact, the ESP doesn't function then.

Any suggestions?

PS: the ESP has its own power since it should trigger a relay to cut power to the printer.


texts: ESP32 and the Microsoft Azure Device Provisioning Service

texts:
I am currently experimenting the the ESP32. In general connecting to WLAN and also to the Microsoft Azure IoT Hub works fine. But unfortunately i coulnt find any information on using the ESP32 with the Microsoft Azure Device Provisioning Service. That means connecting and registering an ESP32 to the Microsoft Azure IoT Hub with a certificate.
Has anyone did this before? Maybe some guiding links etc.?


texts: I have built my own Arduino Due Circuit board. I am having issues with it randomly locking up. I have researched the libraries and have ruled out any issues with them such as the Wire library. I am wondering could an issue with the power supply cause a brown-out that would lock it up. The only way to recover is to unplug it and plug it back in. It can run for 1 hour 1 week or months before it locks up. Does anybody have any idea what could cause this issue and how I can resolve it? Could the fuse or lock bits being set wrong  cause this type of issue?


texts:
I'm trying to print out the temperature from a DS18B20 sensor to my app via a tpc connection. Because I have two sensors connected I will need to call the one needed by an Index. This index comes from my app and is a char value which I need to convert it to an int for comparision later. The problem I have is the conversion from to input char value to int.
My code:

void loop() {
  //setting default sensor to 0
  sensorindex = 0;
  //starting server
  WiFiClient client = wifiServer.available();

  if (client) {
  Serial.write("Client connected");
          client.println("connected");
    while (client.connected()) {
      while (client.available()>0) {

        //instream from client/mobile device
        char c = client.read();
        //converting char c to int
        sensorindex = String(c).toInt() ;
        Serial.println(sensorindex);
      }

      //comparing client input to DS18B20 sensor index
      sensors.requestTemperatures();
      if(sensorindex == 1){
           client.println(sensors.getTempCByIndex(1));
           Serial.println("Index 1");
      }
      if(sensorindex == 0){
           client.println(sensors.getTempCByIndex(0));
             Serial.println("Index 0");
      }

      delay(50);
    }

    client.stop();
    Serial.println("Client disconnected");
  }
}

The serial output:

Client connectedIndex 0
Index 0
Index 0
Index 0
Index 0
Index 0
1
0
Index 0
Index 0
Index 0
Index 0
Index 0
Index 0
Index 0
Index 0
Client disconnected

When I type in 1 from my android app it shows

1
0

in the output. What am I doing wrong?


texts: How should I organize a 3-day Arduino beginners course?

texts: I will be teaching Arduino during a fair in my university, and the school gave me 3 afternoons to teach Arduino to Engineering students. Now I am looking for ideas on how to organize this course, and any help would be very nice.


texts: How can I discard power from a device I want to read from?

texts:
I want to read the data line from a device that normally interfaces with a controller. It has 3 pins, 3.3v power, gnd, and data. I don't need the power line since the Arduino will be USB powered and I obviously don't want to just connect it straight to ground. What would be the best way to handle this without introducing extra hardware components. Can I just connect the power to an input pin, and then I can use that to see if the device is on?

I'm using an Arduino Mega2560


texts: Arduino processing serial comunication - losing data?

texts:
I'm trying to send an array back and forth between Processing and an Arduino UNO. But I think data is being lost along the way. I simply iterate over the array in Processing and send the Values separately. A new set of data is indicated by the character <. On the Arduino the data gets added to a string and sent back for testing.  When I print out the string in processing, some data changed to -1.

The array contains {1,2,3,4,5,6,7,8}

The Output looks like this:

12345678
12345678
1234-1-1-1-1
12345678
12345-1-1-1

Is there something I'm missing in terms of implementation, or is this simply a hardware related problem (like slightly different clock speeds)? Is there any way to improve this?

Arduino Sketch:

int srr[8];

int content; // Data received from the serial port
void setup() {
  Serial.begin(9600); // Start serial communication at 9600 bps
}

 void loop() {
   String str = "val:";
   int test;
   if (Serial.available()){ // If data is available to read,
     content = Serial.read();
   }

   if (content == 60){
     for(int i=0; i<=7; i++)
   {
       str+=Serial.read();
   }
   Serial.println(str);
   }
}

Processing

Serial myPort;  // Create object from Serial class
int arr[]={1,2,3,4,5,6,7,8};  //The array to send

String str;
void setup()
{
  size(200,200); //make our canvas 200 x 200 pixels big
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
}

void draw() {
  //write
  myPort.write("<");
  for (int i =0; i<=7;i++){
    myPort.write(arr[i]);

  }
  //read
  if ( myPort.available() > 0){  // If data is available,
    str = myPort.readStringUntil('\n');         // read it and store it in val
    println(str); //print it out in the console
  }

}


texts:
I am working on a project in which, the mobile app/browser sends HTTP command to ESP8266 in AP mode. The default IP address of ESP is 192.168.4.1. Therefore in order to connect the ESP to WiFi, the command goes like this :- 192.168.4.1/SSID=XYZ/Pass=XYZ.

On connecting to router, the ESP goes into STA mode and Doesn't create AP until WiFi is not found to which it was connected earlier. Now when ESP is connected to router, the router assigns the IP to ESP through which HTTP command will be sent. On Serial monitor, it does show the IP address to which it is assigned, but what if app controls the ESP, there is no serial communication. How will app know the IP address assigned to particular ESP8266? Is there any way app can scan the router? Or any other way to do this? If there are multiple ESP connected to router, how can I identify the IP of particular ESP.


texts: How do I use lambda functions in Arduino?

texts:
I want to pass a lambda function as an argument to a method. Example:
T reduce(const T initial, const std::function<T(T, T)> acc) {
    T value = initial;
    for (size_t i = 0; i < S; ++i) {
        value = acc(value, this->values[i]);
    }

    return value;
}

...

int sum = this->reduce(42, [](int acc, int value) { return acc + value; });

If I try to compile this code for Arduino, I get an obvious error:

error: 'function' in namespace 'std' does not name a template type

How can I use a lambda function in Arduino?


texts: Can I run 3 motion sensors with a voltage regulator?

texts:
I want to power 3 hc-sr501 PIR motion sensors with a voltage regulator that can output 5v-1A.
If I make such a system, will there be a noise?


texts: Why does it say "Servo" does not name a type

texts:
#define pingTrig 6
#define pingEcho 7

#include

Servo myservo;

void setup()
{
pinMode(pingTrig, OUTPUT);
pinMode(pingEcho, INPUT);
myservo.attach(9);
}

void loop()
{
long duration, inches, cm;

digitalWrite(pingTrig, LOW);
digitalWrite(pingTrig, HIGH);
delayMicroseconds(10);
digitalWrite(pingTrig, LOW);

duration = pulseIn(pingEcho, HIGH);

cm = duration / 29 / 2;

if(cm < 10 ){
myservo.write(90);
delay(100);
}else{
myservo.write(0);
}
delay(2000);
}


texts: Why does the PIN 13 LED of Uno R3 blink every time I upload some code?

texts: I was driving a relay from Arduino Uno R3 Pin 13. I observed that every time I upload some code the led on the board designating pin 13 would blink. I'm curious why this is so. I understand that the serial LED blinks cause there's a serial transmission but why an IO pin?


texts:
How do I connect a function generator that generates an analog signal to an Arduino Uno?

I don't know how to begin, so could you also tell me the settings for the function generator, e.g. its amplitude, frequency, etc, that won't damage my Arduino?

I plan to visualize the output on Processing.


texts: Reading Arduino serial data in Octave on Mac

texts:
I am trying to read serial port data generated by Arduino in Octave on Mac. I installed and loaded the instrument-control package for the same. I used this piece of code to check if the package was installed properly

if (exist("serial") == 3) disp("Serial: Supported") else disp("Serial: Unsupported") endif

I do get an output saying Serial: Supported.

I am following the tutorial here for step by step guidance.
I next use s=serial('portname') to create a serial port object. However, I am not sure what name to use instead of COM5 on Windows for Mac.

I checked and my Arduino is connected to cu.usbmodem1421 so I tried following 3 options a)cu.usbmodem1421 b) usbmodem1421 c)1421 but in each case I get an error saying "serial: Error opening the interface: No such file or directory".

Could anyone tell me what port name I can use or if there are any suggestions for the big picture problem as to how to read Arduino serial data in Octave (on Mac)? Thanks for the help in advance.


texts: How to fix Arduino restarting when two servos are powered by an external power?

texts: Can anyone help me fix this? It always restarts when I power the servos with an external battery. I connected one battery to Arduino and one battery to servos, each 5V, but my Arduino keeps restarting.


texts: problem using one function to blink different leds

texts:
I wrote a function to blink an led using millis and want to blink multiple leds with the same function but with different delay intervals. When I call this function thrice to blink 3 different leds, all the leds blink with the shortest delay. As far my understanding is, functions can be reused if you want to perform same task but why doesn't it work in this case? It works incase I rename the function before calling it again.

Is it wrong to call single function more than once to perform same task but on different pins? How would you call a function without renaming it?

const int redLed = 10;
const int yellowLed = 11;
const int greenLed = 12;

void setup() {
  pinMode(redLed, OUTPUT);
  pinMode(yellowLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
}

void loop() {
blinkLed(redLed, 1000);
blinkLed(yellowLed, 4000);
blinkLed(greenLed, 8000);
}

void blinkLed(int led, unsigned long timePeriod) {
  static unsigned long oldTime = 0;
  unsigned long newTime = millis();
  static boolean ledState = LOW;

  if (newTime - oldTime >= timePeriod) {
    oldTime = newTime;
    ledState = !ledState;
  }
  digitalWrite(led, ledState);
}

Edit: I have modified the function to not have shared variables but it just blinks redLed. why doesn't it work now? Here is the code:

const int redLed = 10;
const int yellowLed = 11;
const int greenLed = 12;

void setup() {
  pinMode(redLed, OUTPUT);
  pinMode(yellowLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
}

void loop() {

  blinkLed(redLed, 1000);
  blinkLed(yellowLed, 4000);
  blinkLed(greenLed, 8000);
}

void blinkLed(int led, unsigned long timePeriod) {

  switch (led) {
    case 10:
      static unsigned long oldTime1 = 0;
      unsigned long newTime1 = millis();
      static boolean redState = LOW;

      if (newTime1 - oldTime1 >= timePeriod) {
        oldTime1 = newTime1;
        redState = !redState;
      }
      digitalWrite(led, redState);
          break;

    case 11:
      static unsigned long oldTime2 = 0;
      unsigned long newTime2 = millis();
      static boolean yellowState = LOW;

      if (newTime2 - oldTime2 >= timePeriod) {
        oldTime2 = newTime2;
        yellowState = !yellowState;
      }
      digitalWrite(led, yellowState);
          break;

    case 12:
      static unsigned long oldTime3 = 0;
      unsigned long newTime3 = millis();
      static boolean greenState = LOW;

      if (newTime3 - oldTime3 >= timePeriod) {
        oldTime3 = newTime3;
        greenState = !greenState;
      }
      digitalWrite(led, greenState);
      break;
  }
}


texts: Problems splitting a string to get authentication and command

texts:
Good afternoon,

In a nutshell I'm having some difficulty with splitting and returning part of a string.

Essentially I'm working on the code for transmitting a password (24 character string) and command (string) in a single packet. However, the 'get_command' function is only returning the first character of the string (T) as opposed to the whole string (T1) and I'm not sure why. Any help would be greatly appreciated. Thanks in advance.

The entire sketch is below so you should be able to just drop it in and compile.

char *received_data = "KkV3vKvLgC4PdBZRs5kkKM86T1";
char *password = "KkV3vKvLgC4PdBZRs5kkKM86";

int authenticate_transmission(char *data) {
    if(strncmp(data, password, 24)) {
        Serial.println("no match");
        return false;
    } else {
        Serial.println("match");
        return true;
    }
}

char *get_command(char *data) {
    char command[3];
    strncpy(command, data + 24, 3);
    // Fine here
    Serial.println(command);
    return command;
}

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

void loop() {
    // test received data - message is T1 at the end.
    if (authenticate_transmission(received_data)) {
        char *command = get_command(received_data);
        // But just prints out first char when returned from a function
        Serial.println(*command);
    }
    delay(10000);
}


texts: Come out of loop and execute Setup again

texts: I want to end loop at a specific time and start setup again. Is this possible? (I can explain reason in case you require).


texts:
I have no idea why this has been happening:

byte potenciometro = 0;int redpin=9;

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

void loop() {
int valor=analogRead(potenciometro);  delay(50);
Serial.println();
Serial.print(valor, DEC);

analogWrite(redpin,valor);   }

This code above has been working just fine. However, i understand the LEDs will work properly with intensities that range from 1 to 255, so i replaced this line

Serial.print(valor, DEC);

for this
    Serial.print((valor/700)*255, DEC);

and all that the IDE has been returning since then is 0 as console output.

i tried also just

Serial.print(valor/700, DEC);

and i get nothing but 0s

anyone?

my arduino is the UNO version.


texts: arduino cont down timer in minutes with out using delay

texts:
i have one code with delay pleas help me remove the delay i will using this code in air cooler with some sensors delay stop working sensors

void startCycle(int cycleTimeInMinutes, const char *type) {
  lcd.clear();
  const char *topRow[1] = { type };
  printTopRow(topRow, 1, 5);

  cool1(true);

  for (int cycleTimeLeft = cycleTimeInMinutes; cycleTimeLeft > 0; cycleTimeLeft--) {
    char buffer[2];
    const char *bottomRow[3] = { itoa(cycleTimeLeft, buffer, 10), "Minutes"};
    printBottomRow(bottomRow, 3, 6);
    delay(60000);
  }
  cool1(false);
}