texts: How to send serial data from arduino to xbee and from xbee to another xbee in API mode with escapes?

texts:
I am trying to send serial data from arduino to xbee (series1) and then send to another xbee (series1) wirelessly in API Mode with  escapes. However, can not receive or see  the data on X-CTU. Following is the code. I deeply appreciate your help.

#include <SoftwareSerial.h>
// Arduino pin 9 rx connect to xbee tx, Arduino pin 8 tx connect to xbee rx
uint8_t rx = 9;
uint8_t tx = 8;
SoftwareSerial Serial_xbee(rx,tx);

// variable to store the data received
int sensorValue = 0;

// costant values of the frame
const byte startDelimiter = 0x7E;

  // length
const byte MSB_1 = 0x00;
const byte LSB_2 = 0x10;

  // Frame-specific data
const byte frameType = 0x10;
const byte frameID = 0x0;

  // 64-bit destination address
const byte MSB_5  = 0x00;
const byte b_6    = 0x13;
const byte b_7    = 0xA2;
const byte b_8    = 0x00;
const byte b_9    = 0x40;
const byte b_10   = 0xB1;
const byte b_11   = 0xB1;
const byte LSB_12 = 0x6F;

  // 16-bit destination network address
const byte MSB_13 = 0xFF;
const byte LSB_14 = 0xFE;

  // broadcast radius
const byte broadcastRadius = 0x0;

  // options
const byte opt = 0x0;

byte sending (byte value) {
Serial_xbee.write(value);
Serial.write(value);
return value;
}

void setup()
{
  // starts serial communication
  Serial.begin(9600);
  Serial_xbee.begin(9600);
  pinMode(7, INPUT);

}

void loop()
{
  // send data through xBee
  sending(startDelimiter);
  sending(MSB_1);
  sending(LSB_2);
  long sum = 0; // accumulate the checksum
  sum += sending(frameType);
  sum += sending(frameID);
  sum += sending(MSB_5);
  sum += sending(b_6);
  sum += sending(b_7);
  sum += sending(b_9);
  sum += sending(b_10);
  sum += sending(b_11);
  sum += sending(LSB_12);
  sum += sending(MSB_13);
  sum += sending(LSB_14);
  sum += sending(broadcastRadius);
  sum += sending(opt);
  sum += sending(0X10);  // this is the payload[0] byte
  sum += sending(0X10);  // this is the payload[1] byte
  sending( 0xFF - (sum & 0xFF));
  delay(2000);
}


texts: USBasp problem: could not upload sketches to Arduino clone with PL2303 USB-to-UART chip

texts:
I'm trying to upload sketch to a Gizduino board (these boards have PL2303 chip for USB-to-Serial communication; other than that they are entirely similar with Arduino Uno).

I have installed the driver for it and can verify that the board associates to a COM Port whenever the board is connected to my PC (Win10) via USB. But everytime I try to upload a sketch, IDE (tried with 1.8.2 and 1.6.9) throws the error below, with or without the PL2303 driver installed on my PC.

avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'

I'm certain that I have selected the right board from the Boards List.

So my intuition was that the PL2303 driver is not working the way it should be. I've been trying to get more information about avrdude and USBasp but so far was not able to find anything remotely similar to my case.

UPDATE: Realized that all I needed to do is install the driver for USBasp (whihch I'm having trouble doing); this post could be off-topic. But I'm urged to raise another question: Which programmer should I select from the programmer list? Currently its "AVRISP mkII". In fact it doesn't matter which one I use. Same error about USBasp occurs with any of them selected.


texts: Where Can I Find a 12v Solder-less Breadboard Power Supply?

texts:
I am trying to find a 12v input and 12v output breadboard power supply but I can't find one. I am making an arduino-controlled lock but the Arduino cannot power the lock strike by itself so I need to use a seperate power supply. The link to make things clearer:
http://www.instructables.com/id/Arduino-RFID-Door-Lock/#step0


texts: Want to decrease the number of power supplies from 4 to just one

texts:
Hello everyone I have 4 stepper motors 2 being nema 23 and 2 being nema 17 with nema 23 rated at 2.8 amps and nema 17 rated at 1 amp also the servos are tower pro mg995.
I want to decrease the number of power supplies from 4 to just one either by creating one as I want to scale up my work and don't want a lot of power supplies for just making some motors spin.

Please help me create a power supply that can work for my appliance.
Also to mention I am using A4998 driver for nema 17 and TB6600 drivers for nema 23 and all the connections are in parallel.
Thank you, you guys are amazing.


texts: Use transistor to press button on external device

texts:
I have a small device with a simple push button. I'd like my Arduino to be able to make the device register button pushes. It seems like the best way to do this is to use a transistor to close the circuit for the button when my Arduino sends it a pulse from one of its pins. I've mapped out what I think the circuit should look like on a breadboard. I didn't include the device in this diagram, but it's powered by a CR2032 watch battery, which seems to give 220 mAh at 3Vs.

Basically, the two sides of the button would be connected to the transistor's collector/emitter leads. Then the digital pin on my Arduino would be connected via a resistor to the base lead on the transistor. When the pin sends some current to the base lead, the transistor will make current flow through it and the device will register a button press.

I made this by adapting the circuit here, which looks like this:

Basically I got rid of the motor/load and flyback diode, and hooked the two ends of the device's button up to the collector/emitter leads of the transistor.

I'm concerned that I've screwed up this circuit somehow, and will fry either the device or the Arduino or something else when I try and run it, otherwise I'd just test it right away.

Could anyone give me feedback if I'm on the right track here? I couldn't find other answers which dealt with quite this setup, where you are pressing a button on another device, though this question seemed related.


texts: What's the difference between all the Software Serial Libraries? Which one is Arduino Nano compatible?

texts:
There are so many Software Serial Libraries, what are the differences between them? And which one I can use with my Arduino Nano? For my Arduino Nano I need one Hardware Serial Port and one Software Serial port at a baud rate of 115200.

On which pins of the Arduino Nano can I use the software serial library?


texts: Transmitting sketches to Yun with Autobahn - a byte at a time?

texts:
I am using this tutorial to connect an Arduino Yun with a browser using Autobahn.

In the python file in the above repo, there is this code:

def controlLed(self, turnOn):
    if turnOn:
        payload = b'1'
    else:
        payload = b'0'
    self.transport.write(payload)

Here's the thing - I need to send whole sketches to my Yun, not just '1' or '0'. I tried sending more to the payload (like payload = b'this is part or all of a sketch') but that doesn't work. I experimented with some other data types but at the moment these are shots in the dark.

How can I send some proper data (like 100 lines of Arduino sketch) with this mechanism? The end goal is that my existing sketch receives the new sketch commands via serial and runs them.

if (port->available()) {
  int commands = port->read();
  // Run commands here
}

I would be hugely appreciative of any help. Thank you!


texts: Do I need more voltage to close this circuit?

texts:
I'm hacking together a RF-controlled garage door opener. I'm tapping the "receiving" end in to the push button wires.

When the two wires touch, it toggles the garage door motor.

I'm trying to basically "close" this circuit through a 5V Trinket Pro with...

pinMode(A0,OUTPUT); in setup and digitalWrite(A0,LOW); in the loop.

Using the multimeter, it would seem that the wires for the push button are normally closed (I think that's correct) as I get a 15v read on the multimeter when I check the current.

When I touch the wires, the current drops to 0.

My understanding was that the digitalWrite(A0,LOW); would basically "complete" the circuit, but it doesn't seem to do anything.

So, my question is: Given I've only got 5v running through the Trinket Pro, is that not enough to toggle the garage door circuit given it's putting out  15v in it's NC state?

If that's the case, is there some other way around that without needing to push 15v of power?


texts: How to calculate the RZERO value in MQ135 sensor, I have already burned it for 24 hours?

texts: I've already burned it for 24 hours and it is now giving the constant value of 932.36,pls tell me how to calculate the RZERO value.


texts: How to read data from a rotary encoder with ATmega328

texts:
I'm using a home made "bare bones" Arduino, made with the ATmega328, and I need to read angle data from a geared DC drill motor, turning at speeds between 0 and 450 RPM. This is so I can use it as feedback for an angle control system implemented on the Arduino.

I've not yet bought the encoder. I'm waiting until I find a suitable one which works easily with Arduino.

I have already written the control algorithm. I'm using state variable feedback, and the algorithm depends on a getAngle() function that I have not written yet. This function is inside an if statement that executes every 0.2 seconds. It needs to return the angle of the DC motor in degrees.

My questions:

How can I implement this getAngle() function using a rotary encoder?
What is an example of a rotary encoder that is suitable for this application?
Will it be better to use the interrupt pins of the Atmega328, or use some other method?

I have seen a few library's on Arduino Playground that claim to make reading angle data easier, but how do I use them? I need something that is fast (it, and the control algorithm operations, both needs to finish before the 0.2 seconds sample time), and more importantly it needs to be easy to implement. I'm coming up to the project deadline so I don't want to have to spend a whole day figuring out how to implement this getAngle() function.

Thank you!


texts: Can I change Arduino program on-the-fly?

texts:
I have Arduino which is programmed to do something. Is it possible that I could allow it to change behaviour by changing program on-the-fly without the need to reprogram Arduino via the computer.

What I need is to send the message via MQTT which will Arduino receive and change its behaviour by it. I managed to change the frequency of messages published or to add some new data, but what if I want to change how decisions are made. What if I want to change some Arduino code, to add some if or another state, can that be done on the fly?

Update: Changing device behaviour on the fly or after restart is acceptable. I am not strict with using arduino, nodemcu is and option. I just need a way to add new functionality to device if I need.


texts: Unable to compare char from radio (RF24)

texts:
The code below is receiver code using nRF24L01. In the loop section I'm comparing the char that was being sent from the Arduino transmitter. In this case the char array says "I'm off" just like the char array compare below. Even though the text is the same, it does not do what it is supposed to do.

Basically the if function below does not seem to work for some reason, both are char arrays (the text[32] and compare[32]) and both will have the same value which is "I'm off" yet it is not registered as the same thing. I cannot figure out what is wrong with the code, please help.

This is the receiver code. The question is about the if function in the loop below.

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

RF24 radio(7, 8); // CNS, CE
const byte address[6] = "00001";

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}

void loop() {
  if (radio.available()) {
    char text[32] = "";
    char compare[32] = "I'm off";
    radio.read(&text, sizeof(text));
    Serial.println(text);
    Serial.println(compare);
    // this is the problem  -->
    if (text == compare) {
      // it is supposed to print this but it does not -->
      Serial.println("not on");
    }
  }
}

This is the transmitter code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CNS, CE
const byte address[6] = "00001";
const int button = 5;

void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
  pinMode(button,INPUT);
}

void loop() {
  int reading = digitalRead(button);
  if(reading == HIGH) {
    // send a message to the radio
    const char text[] = "I'm on";
    radio.write(&text, sizeof(text));
    delay(1000);
  }
  if(reading == LOW) {
    // send a message to the radio
    const char text[] = "I'm off";
    radio.write(&text, sizeof(text));
    delay(1000);
  }
}


texts: Benchmarking String.toInt() vs Checking individual characters gives unexpected result

texts:
I'm trying to check whether the input string contains all digits or not. I achieved this using 2 different algos. One is to convert the string to integer using String.toInt() and then checking if its value lies between the integer of length of the input string.

e.g. If input string is "123". The corresponding integer must lie between 100-999.

Second, I wrote a function that iterates over each character of the string and checks if its ASCII values lies between 48-57. If not, it returns false.

When I bench marked these two algos, I found that when the string contains only digits, the 2nd algo is about 9 times faster than the 1st one. But when the string contains even a single non-digit character, the 1st algo takes ~1ms, but the 2nd algo always takes ~5ms. Why is this? I've not been able to figure this out.

The code:

unsigned long start;
unsigned long middle;
unsigned long end;

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

  // send an intro:
  Serial.println("String toInt():");
  Serial.println();
}

void loop() {
  // Read serial input:
  if (Serial.available()) {
    String r = Serial.readString();

    start = micros();
    unsigned long rInt = r.toInt();
    int rLen = r.length();

    if ((rInt >= floor(pow(10, rLen))) || (rInt < floor(pow(10, rLen-1)))) {
      Serial.println("Please enter valid integer value!");
    } else {
      Serial.println(rInt+1);
    }

    middle = micros();

    bool isInt = doesContainInteger(r);
    if (isInt) {
      Serial.println(r);
    } else {
      Serial.println("Please enter valid integer value!");
    }

    end = micros();

    Serial.println(middle-start);
    Serial.println(end-middle);
  }
}

bool doesContainInteger(String s)
{
  int sLen = s.length();
  for (int i=0; i<sLen; i++) {
    char sChar = s.charAt(i);
    if (sChar<48 || sChar>57) {
      return false;
    }
  }
  return true;
}


texts: Difference between DS1307 and IN1307N, I am using RTClib for making rtc module using IN1307N getting RTC is not running

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

#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
#define Serial SerialUSB
#endif

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {

#ifndef ESP8266
while (!Serial); // for Leonardo/Micro/Zero
#endif

Serial.begin(9600);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}

if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
}

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

Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();

Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");

// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now + TimeSpan(7,12,30,6));

Serial.print(" now + 7d + 30s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();

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

If i use 57600 i'll get random symbols in one line 1 line.
I have connected PIN5 IN1307N to A4, PIN4 IN1307N to A5


texts:
Alright so I've been trying to update/change the number on the display during a loop, but nothing really happens. It doesnt change/update, the value is always exactly same.

#include <TM1637Display.h>

#define led_display 1
#define led_display_scnd 3

int analogPin = A0;
int moisture;
int percentage;

int map_low = 686;
int map_high = 350;

TM1637Display display(led_display_scnd, led_display);

void setup() {
  pinMode (led_display, OUTPUT);
  display.setBrightness(1);

  display.showNumberDec(1);
  digitalWrite(led_display, HIGH);
  Serial.begin(9600);

}

void loop() {
  display.showNumberDec(5);
  moisture = analogRead(analogPin);
  Serial.print("Raw: ");
  Serial.print(moisture);

  int sensorValue = analogRead(A0);
  percentage = 100-((sensorValue-110)*100L/(1023-110));

  Serial.print(" | Percentage: ");
  Serial.print(percentage);
  Serial.println("%");

  display.showNumberDec(moisture); // updating the value

  delay(2000);
}


texts: I just fried my Arduino on a breadboard. Can I still use the breadboard?

texts: So, I just fried my arduino nano on a breadboard. Can I still use the breadboard and usb cable?


texts:
What is the maximum number of serial ports (com) can Arduino IDE detect ?

I need to connect 6 Arduino UNO Wi-fi at a time to make a small network and I use a 7 port USB hub for the same. The device manager shows 6 com ports detected but Arduino shows only 4 serial ports detected. Is there a limitation on the serial ports interfaced with the Arduino IDE ?


texts:
Would it be possible to instead of passing a state via a REST browser:

digital/13/1

to set an int value? For example, if in the sketch if I would name an int: 2, could I set this to 48 via REST?

If so, how?


texts: ESP8266 WiFi Not Connecting to Internet Without Static IP

texts:
I am seeing some very strange behavior with my ESP8266. When I connect it to the WiFi for the first couple of times I am not seeing any issues and the ESP8266 connects just fine.
But after an arbitrary amount of times (like when I restart the unit) it tries to connect for AGES (like multiple minutes). Eventually it says "Connected" but the IP is completely wrong and it is not connected to the internet (GET request fails).
Here are the odd things:

If I assign a static IP then it ALWAYS works and connects within seconds
If I factory reset my router then it works again for a few times
I have not seen this with any other device (like laptops or cellphones)

It is almost as if the DHCP is failing to assign an IP and then returns some random default.
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

// Replace these with your WiFi network settings
const char* ssid = "MYSSID"; //replace this with your WiFi network name
const char* password = "MYPASSWORD"; //replace this with your WiFi network password

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

  IPAddress ip(192,168,1,77);
  IPAddress gateway(192,168,1,1);
  IPAddress subnet(255,255,255,0);

// If I uncomment this line then it works fine
//  WiFi.config(ip, gateway, subnet);

  WiFi.begin(ssid, password);

  Serial.println();
  Serial.print("Connecting");

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

  Serial.println("success!");
  Serial.print("IP Address is: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  HTTPClient http;

  String serverPath = "http://www.google.com";
  http.begin(serverPath.c_str());

  // Send HTTP GET request
  int httpResponseCode = http.GET();
  Serial.print("HTTP Response code: ");
  Serial.println(httpResponseCode);
  String payload = http.getString();
  Serial.println(payload);
  // Free resources
  http.end();

  delay(1000);
}

When DHCP magically works it assigns: 192.168.1.159
When DHCP does not work I get: 169.254.104.241
When I use a static IP then the static IP is assigned.
So the question is: Has anyone seen this behavior and maybe give some hints about how I can get the internet connection to be consistent without needing a static IP?
Update:
If I run a ping to 169.254.104.241 I get a reply. But if I try to get anything from the internet I get HTTP Response Code = -1.


texts: Has anyone modified a 16x2 LCD shield to work with Arduino DUE?

texts:
Since the DUE works on 3.3 volts has anyone successfully modified a 5V 16x2 LCD shield to work with Arduino DUE?  I'm thinking 3.3V will be seen as a logic "1"
by the 5V LCD shield and there are no 5V outputs that feed back to the 3.3V due if the R/~W line on the LCD is simply grounded.

Would love to hear anyone's opine on this.

Thanks,
Charlie


texts: NRF24L01+ how much supply ripple is acceptable?

texts:
I'm trying to get a simple TX/RX pair to work. I've got identical Nanos and I'm using the example from:
http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo

I followed the advice about adding a cap across the Vcc GND on the nrf board, and added a 10uF electrolytic to both.

I still haven't received a packet yet, and I wondering how to eliminate the power supply as a cause. I scoped the power pins, and even without a cap I got about 250mV of ripple. With the cap it goes down to about 100mV. Is this within tolerance? What kind of caps does anyone else use, and has anyone scoped the result to see where the threshold lies?

Aside form that, are there any other clever ways to debug this issue?

Update 20160122. I finally tested using those cheap piggyback 3.3v regulator boards that plug straight into the nrf board. Works perfectly, not one lost packet over 5000 packets sent. Interestingly, the RX side appears to be the fussy one. Thanks to everyones' suggestions. For a total combined cost of about 4$ per node, I have a great wireless TX/RX solution.


texts: Error while updating ThingSpeak using SIM808

texts:
im trying to update ThingSpeak from a SIM808 but I'm getting a network error. Please check below and let me know if there is anything wrong in my methodology.

I'm using terminal.exe to send commands via RS232.

AT
OK
AT+CREG?
+CREG: 0,5 //connected in roaming
AT+SAPBR=3,1,"Contype","GPRS"
OK
AT+SAPBR=3,1,"APN","www" //VODAFONE INDIA "www" is APN (as per the operator)
OK
AT+SAPBR=3,1,"USER","" //blank (as per the operator)
OK
AT+SAPBR=3,1,"PWD","" //blank  (as per the operator)
AT+SAPBR=1,1
OK
AT+HTTPINIT
OK
AT+HTTPPARA="CID","1"
OK
AT+HTTPARA="URL","https://api.thingspeak.com/update?api_key=MY_KEY&field1=VALUE"
OK
AT+HTTPACTION=0
+HTTPACTION: 0,603,0

Note: while I'm typing in the browser url box, https://api.thingspeak.com/update?api_key=MY_KEY&field1=VALUE, I can update my field. I can make calls, send SMS. I have an internet pack.

Please help.


texts: FlexyStepper: wrong behavior when changing target during movement

texts:
I'm using the FlexyStepper library. Unfortunately there's no way to open an issue on GitHub so I'm going to ask my question here.
I think there's a bug in the calculations. In my application (it's not a CNC, just a rotary axis used for theatrical effects) I may need to change the target even if the current target has not reached yet.
This is supported by the library, there's also an example.
I modified this example and created this small sketch to simulate the problem:
#include <FlexyStepper.h>

const int MOTOR_STEP_PIN = PE13;
const int MOTOR_DIRECTION_PIN = PE14;

#define TARGET_HIGH 2000
#define TARGET_LOW  0

FlexyStepper stepper;
unsigned long previousMillis = 0;
unsigned long target = TARGET_LOW;
int cycles = 100;

void setup()
{
  Serial.begin(115200);
  stepper.connectToPins(MOTOR_STEP_PIN, MOTOR_DIRECTION_PIN);
  stepper.setSpeedInStepsPerSecond(5000);
  stepper.setAccelerationInStepsPerSecondPerSecond(1000);
  stepper.setCurrentPositionInSteps(0);
  delay(5000);
}

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

  if (currentMillis - previousMillis > 1000)
  {
    previousMillis = currentMillis;

    if (cycles)
    {
      if (target == TARGET_LOW) target = TARGET_HIGH;
      else target = TARGET_LOW;

      stepper.setTargetPositionInSteps(target);
      cycles--;
    }
    else
    {
      stepper.setTargetPositionInSteps(0);
    }
  }
  stepper.processMovement();
}

At first, it remains still at position 0 for few seconds so you can take a note where it is.
Then, every seconds it changes its target between TARGET_LOW and TARGET_HIGH. Of course it cannot reach them because the new target comes before the current has reached.
At the end, it returns to 0.
I expected the motor oscillates between the two points in a symmetrical way (because acceleration and deceleration are the same). Instead it moves randomly but the most important thing is the final 0 is very different than the initial one.

I'm using professional stepper and drivers (23SM080-028-8W-F10-1.7-CE and MSD-50-5.6-D). I'm not new to stepper motors and I'm sure I'm not loosing steps. I set the current slightly over the nominal one to test it. And the speed/acceleration settings are very small for such a motor.
Any idea why it seems to do the wrong math?


texts: Wiring Multiple MPU 6050 to Micro/Lenardo

texts:
disclaimer I am new at hardware/circuits
I am currently trying to connect two MPU-6050 to a single Micro board.
In addition, there are 5 additional buttons to be connected.
I am under the impression to connect multiple devices to the I2C bus, there must be unique addresses. I read there was a way to make unique addresses (https://playground.arduino.cc/Main/MPU-6050/#multiple).
However I am not sure of the wiring or if the voltage/resistors/anything is supposed to be located.
I have a sketch of what it may look like.

Can anyone help me verify that this is the proper configuration? Or what a proper configuration would look like?


texts:
My HM-10 bluetooth module is behaving weird.

In order to have it operate normally, I have to keep holding the small black button on it. If I ever release the button, it just disconnects from my phone (if it was connected) and doesn't show on the bluetooth devices list anymore, and its red LED light becomes low, not bright as usual.

It operated normally before.

How can I fix this?

What would some possibles causes be for this weird behavior?

UPDATE: picture showing the button on lower right corner.


texts: Arduino Uno WiFi Rev2 "no socket available"

texts:
My Uno WiFi Rev2 outputs on the serial monitor after ~30 min "no socket available". Until that point everything works just fine, my requests run as expected. I use the .flush() and .stop() commands, as in several forums suggested. In the following my really messy code (sorry for that, but it's not optimized and only for testing some stuff):

#include <SPI.h>
#include <WiFiNINA.h>

//W-Lan Data
int status = WL_IDLE_STATUS;
char ssid[] = "**********";
char pass[] = "**********";

bool jsonBool;
char jsonChar;
int curlyBracket;
String jsonCode;
String json;

IPAddress HueBridge(10, 0, 0, 30);

WiFiClient WHTTP;

void setup() {
  while (status != WL_CONNECTED) {
    status = WiFi.begin(ssid, pass);
    delay(500);
  }
}

void loop() {
  jsonProcessing();
  httpRequest();

  bar1();

  delay(55);
}

void httpRequest() {
  WHTTP.flush();
  WHTTP.stop();
  if(WHTTP.connect(HueBridge, 80)) {
    WHTTP.println("GET /api/*************/lights/ HTTP/1.1");
    WHTTP.println("Host: 10.0.0.30");
    WHTTP.println("Connection: close");
    WHTTP.println();
  }
}

void jsonProcessing() {
  while(WHTTP.connected()) {
    if(WHTTP.available()) {
      curlyBracket = 7;
      while(WHTTP.available()) {
        jsonChar = WHTTP.read();
        if((jsonChar == '{') && (curlyBracket == 7)) {
          jsonBool = true;
          curlyBracket = 0;
        }
        if(jsonChar == '}') {
          jsonBool = false;
          jsonCode = jsonCode + '}';
          curlyBracket++;
        }
        if(jsonBool) {
          jsonCode = jsonCode + jsonChar;
        }
      }
    }
    WHTTP.flush();
    WHTTP.stop();
  }
  jsonBool = false;

  //processing jsonCode variable

  jsonCode = "";
}

void bar1() {
  //calculating stuff
}

If anything is unclear feel free to ask. This is not the whole code, just the WiFi relevant parts.

The main structure is copied from here https://www.arduino.cc/en/Tutorial/WiFiNINAWiFiWebClientRepeating
so it theoretically should work.

Thanks in advance.


texts:
I have a Nano clone here, that sporadically fails to get detected by my banana pi. This is annoying, because it works for days and hours, but fails to work randomly.

The Nano gets it's own power via VIN and thus should have enough power.

I thought of bypassing the FTDI and make a Serial connection via 2 Wires. Alternatively: Is there a way to force the arduino to use external Power over USB. I have the feeling, the the arduino wrongly decides, that USB is the better power source and uses it, causing the errors ( device not accepting address 21, error -62 )

P.S.: There is also a touch-screen connected to the banana pi via USB. Whatever port I use, It works and never failed. Just the Nano fails from time to time.


texts:
I am trying to interface with the ICM-20789 over I2C. DataSheet

I have been successfully able to get all three gyroscope readings and all three accelerometer readings. I am now trying to get the pressure readings from the device, since it has a built-in pressure sensor, but cannot seem to get it working.

In the datasheet, it says to enable Bypass Mode.

  Bypass Mode: Set register INT_PIN_CFG (Address: 55 (Decimal); 37 (Hex)) bit 1 to value 1 and I2C_MST_EN bit is ‘0’
  (Address: 106 (Decimal); 6A (Hex). Pressure sensor data can then be accessed using the procedure described in Section 10

In the setup I use this code:

  Wire.beginTransmission(gyro_address);
  Wire.write(0x37);      //INT_PIN_CFG
  Wire.write(0x02);      //00000010
  Wire.endTransmission();

I am having trouble finding I2C_MST_EN in the datasheet as well, as I cannot find it in the 6A Address.

Once I have the bypass bit enabled, I try to request the pressure and temperature data from the sensor using this code:

Wire.beginTransmission(0x63);
Wire.write(0x7866);
Wire.endTransmission();
Wire.requestFrom(0x63, 16);

while (Wire.available() < 16);
pressure = Wire.read() << 16 | Wire.read() << 8 | Wire.read();
temp_2   = Wire.read() << 16 | Wire.read() << 8 | Wire.read();

Unfortunately, the device freezes when I try to run this code. I know I am obviously doing something wrong here, just don't know exactly what yet.


texts:
I was using OTA to upload sketches to ESP ports I have ( around 10 ESPs).
For some time now - I'm having some kind of a trouble I would like to share, since I've read some similar topics, but all didn't work.

The problem is when trying to select Network Port as I did before, sometimes I see all, sometimes part, sometimes only one or two, and sometimes after selecting to one I want to upload to, it fails since it disapears from that list by the time it starts the upload.

I'm using IDE 1.8.8 on a Linux machine - same issue,

Tried on mac, using both 1.8.8 and even downgraded to 1.8.7 - and I'm getting the same issue.

What might be the cause for that ?


texts: Wired serial connection between two Arduinos - do they need a common Ground (GND)?

texts: I would like to connect two Arduinos by a serial connection. Is it sufficient to connect TX1<-->RX2 and RX1<-->TX2 or do I also need to connect the GND of the two Arduinos?


texts: Arduino Pro Mini maximal and recommended current per pin

texts: In Arduino Pro Mini (3.3V) specs indicated the maximal and recommended current per pin, 40mA and 20mA respectively. Does these values means input current (i.e. safe input current Arduino can handle) or output current?


texts: Stuck in a loop when reading from EEPROM, works if I clear it first

texts:
EDIT: The problem was caused by storing a pointer in the EEPROM. Thanks to @KIIV for helping out

Sorry for the enormous of wall of text, I'm trying to pare it down a bit.

I have two Arduino Megas that are misbehaving. Both boards produce identical output, so I'm certain it's not a hardware issue.

I'm trying to store user configuration data on the EEPROM and load it when the arduino boots. I have an object which contains flags for user settings like baud rates and serial port modes.

During void setup(), it fails to load the config from the EEPROM. It gets stuck looping through a few functions, even though those functions are not loops at all.(more details below)

However if I clear the EEPROM during void setup(), I can then save and load configurations later on, using menus invoked by the user during void main(). This works flawlessly. I'm calling the same load function in both cases, it just causes the arduino to shit itself if I call it during setup().

Here is a condensed version of my code:

struct UserCfg {/* config options */}

void ConfigController::load_eeprom_cfg()
{
    Serial3.println("loading from eeprom");
    EEPROM.get(gp::config_address, UserCfg);
}

void ConfigController::write_user_config()
{
    Serial3.println("writing user config to eeprom");
    EEPROM.put(gp::config_address, UserCfg);
}

void ConfigController::apply_user_config()
{
    /* other serial ports omitted */
    Serial3.begin(UserCfg.serial_cfg_3.ser_speed, UserCfg.serial_cfg_3.ser_mode);
    Serial3.write("serial 3 up\n\r");

    // Allows users to set the admin terminal to any serial port
    Admin_Serial = UserCfg.admin_serial_port;
    Admin_Serial->write("Admin terminal up on this port\n\r");
}

/// checks and loads config at system boot
void ConfigController::startup()
{
    Serial3.begin(9600);
    Serial3.println("loading...");

    load_eeprom_cfg(); //<----- Not working when called here.

    // prevents loading non-existent config. Not robust, but it works for now.
    if (UserCfg.admin_port_str == nullptr)
    {
        Serial3.println("No valid config found. Using defaults.");
        write_default_cfg();    // puts hard coded defaults in the EEPROM.
        load_eeprom_cfg();      // works just fine when called here
    }
    Serial3.println("Applying...");

    apply_user_config(); //<----- Also not working when called here.
}

// Main code:

void setup()
{
    // erase_EEPROM() is is copied from the official arduino tutorial.
    ConfigController.erase_EEPROM();     // If I comment this line out, it breaks.
    ConfigController.startup();
    Serial3.print("startup done");
}

If I remove the call to erase_EEPROM from void setup(), the arduino gets stuck in a loop:

loading...
loading from eeprom
Applying...
serial 3 up

Those lines just repeat over and over.

However, when I call it exactly as you see above in void setup(), it works perfectly. The EEPROM is erased, the IF statement in ConfigController::startup() catches the bogus value, and writes the default config to the EEPROM. Once it's done, it reads it back from the EEPROM into the UserCfg, which is displayed in the menus. I can then save / load values to my hearts content from the menu like this:

write_user_config();
load_eeprom_cfg();
apply_user_config();

or for loading defaults:

write_default_cfg();
load_eeprom_cfg();
apply_user_config();
print_menu_prompt();  // This includes values from UserCfg, so I can confirm that changes are saved and then loaded.

I fail to see a functional difference between calling load_eeprom() during void setup(), vs calling it during void main(). It's the exact same function that put the value in the EEPROM to begin with.

Any help?


texts: How can I run two Arduinos in sync for video generation?

texts:
I was thinking about building a video circuit that uses two Arduinos (maybe more) to generate video using NTSC and the AD725.  Although, VGA might be nice if possible.

Anyway, the idea is to use one Arduino as the background layer and the other one as the sprite layer (overlay).

Then, instead of masking the sprite data and having more cpu time, I was thinking of running the signals through a mux.  So that when drawing background data and no sprites (per scanline) then pipe the signal to the AD725.  But when there is a sprite mid-line, then the >0v signal of the sprite Arduino would cause the mux to pipe its contents through to the AD725.

Or, something similar.

I believe many arcade boards from the 80's did this.  Many of them had entire "sprite boards" attached and the signals would mix.  Each layer would have it's own RAM and not be aware of the other layer.

But to do this, I would have to keep the Arduinos sync'd perfectly.

So that's my question.  How I can do this?

Oh, my Arduino of choice in the beginning would be the UNO but I have others (DUE, Teensy3.1, etc.) if that would be a better fit.

Thanks.


texts: Why ATMEGA328P U-TH doesn't answer to USBasp but work fine with Arduino as ISP?

texts:
I ordered ATMEGA328P AU from China recent but I got "ATMEGA328P U-TH". which seem super problematic.
I try to use USBasp to burn bootloader but it fail and show error message as shown.
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
     Double check connections and try again, or use -F to override
     this check.

which I believed many people face same situation as mine. Then I accidentally found the solution by using Arduino as ISP which successfully birn bootloader. After that I can use USBasp to upload sketch or burn bootloader.  I don't understand what happen here.
Note: I solder ATMEGA328P U-TH in SMD package to Arduino UNO clone.


texts: How to wake up Arduino Mega when in Power Saving Sleep Mode?

texts:
I'm using sleep mode to turn off my device after the routine has finished executing and want to use interrupts to wake it up every 33 milliseconds. Basically, the idea is that if the routine completes in less than 33 milliseconds the processor can shutdown and save power for whatever remaining time, which will hopefully translate to reduced power consumption. I've currenlty managed to turn off my device with the sleepNow() function you see below, but the interrupt I have programmed in doesn't seem to work. The program simply goes to sleep and never wakes up. What am I doing wrong?

#include <avr/interrupt.h>
#include <avr/power.h>
#include <avr/sleep.h>

const uint16_t PERIOD = 2150;

void setup()
{
  noInterrupts();
  TCCR1A = 0;            // undo the timer config done...
  TCCR1B = 0;            // ...by the Arduino core library
  TCNT1 = 0;             // reset the timer
  OCR1A = PERIOD - 1;    // set the period
  TIMSK1 = _BV(OCIE1A);  // enable TIMERx_COMPA interrupt
  TCCR1B |= (1 << CS12); // ...and set the prescaler
  interrupts();

  Serial.begin(9600);
}

ISR(TIMER1_COMPA_vect)
{
  Serial.println(millis());
}

void loop()
{
  Serial.println("Program is on");
  Serial.flush();
  sleepNow();
}

void sleepNow()
{

    // Choose our preferred sleep mode:
    set_sleep_mode(SLEEP_MODE_PWR_SAVE);

    // Set sleep enable (SE) bit:
    sleep_enable();

    // Put the device to sleep:
    sleep_mode();

    // Upon waking up, sketch continues from this point.
    sleep_disable();

}


texts: Can't compile my library because "String does not name a type"

texts:
I am writing a small library to move some code out of the arduino sketch and make it reusable. Problem is that it does not compile since "String does not name a type".
This is my code (reduced):
myESP.h:
#ifndef MYESP_H
#define MYESP_H

#include "Arduino.h"

#include <String>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>

class myESP {
    private:
        const char* _ssid;
        const char* _password;
        const char* _host;
    public:
        myESP();
        myESP(char * ssid, char * pwd, char * host);
        String macToStr(const uint8_t* mac);
        String doGet(String data, String sensor, int duration);
};
#endif

myESP.cpp:
#include <String>

#include "Arduino.h"
#include "myESP.h"

myESP::myESP() {}

myESP::myESP(char * ssid, char * pwd, char * host) {
    _host = host;
    _password = pwd;
    _ssid = ssid;
}

myESP::String macToStr(const uint8_t* mac) {
}

myESP::String doGet(String data, String sensor, int duration) {

}

When i try to compile it, I get the following:

/Users/lbedogni/Documents/Arduino/libraries/myESP/myESP.cpp:14:1:
error: 'String' in 'class myESP' does not name a type  myESP::String
macToStr(const uint8_t* mac) {
/Users/lbedogni/Documents/Arduino/libraries/myESP/myESP.cpp:22:1:
error: 'String' in 'class myESP' does not name a type  myESP::String
doGet(String data, String sensor, int duration) {

I have tried to change the order of the imports, change libraries, but still it does not compile.
Any idea?


texts: I2C seems to stop working when I attach an AF motor shield

texts:
I have a cheap MPU 6050 chip that communicates over 3.3V I2C. I can talk to it just fine on my Leonardo. If I add an additional Adafruit Motor shield (the old one), my MPU 6050 demo sketch hangs somewhere, and I get nothing back.

As far as I see, the pins I use for the I2C communication are not used at all by the motor shield.

What could be wrong here?

I have the MPU6050 connected to SCL, SDA, GND and 3.3V, the motor shield uses almost all other pins.

Additional Info:
I am using this sketch currently: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050

Update:
Lots of "Serial.println"s later, I've narrowed it down a bit. The example sketch above hangs on the statement "Wire.endTransmission();" on line 279 of the I2CDev library.

Update:
Connecting the motor shield to external power seems to fix my problem. Weird =) I am still interested in the reason for this behavior.


texts: Use Arduino IDE to program Bluetooth Bee standalone

texts: Using Arduino IDE, how do I program the Bluetooth Bee Standalone?  I can't select that particular board from the list under Tools -> Board.  The closest I see is Arduino Fio.


texts: FIFO overflow with DMP on MPU6050 and OLED

texts:
I am using the DMP example code to get yaw pitch roll values, mainly I am interested in pitch value for building a self balancing robot. I am trying to display the pitch values on an OLED screen but I am getting FIFO overflow error which is resulting in delayed sampling and sometimes erratic values.
I tried adding a mpu.resetFIFO() after updating the OLED, but its causing a very slow sampling of the sensor.
I am keen on changing the Arduino Uno for a Teensy board(prolly teensy LC). My main concerns are will changing the processor help? Teensy LC runs @48Mhz compared to Arduino Uno which runs @16Mhz.
Also I went through this link which I found as a probable solution but wasn't able to do it
https://www.i2cdevlib.com/forums/topic/27-fifo-overflow/#comment-99
would be great if someone could guide me as to how do I do this?


texts: Updating SPI transfer16 to create Transfer24

texts:
It might be a bit out there, but for a project that I am working on, my word size default is 24bits (3x8-bit), of which the first 8-bits are data and the next 16-bits are data. I would like to transfer it out of the system as fast as possible with minimal calls to the sub-routines. For this I am trying to reduce the number of calls, I have managed to reduce it from 3 to 2, Can I possibly make it 1 call.

My first attempt was to use 3x SPI.transfer() Second was to use 1x

SPI.transfer() and 1x SPI.transfer16()

I would like to know what would be the ideal way to write a SPI.transfer24 function.


texts: Ultra Long Range (200-500km) Arduino Communication using a Gibson Girl

texts:
I came across this article on Hackaday showing a simple AM transmitter sending a morse code tone 700km!

I'm looking into a EPIRB for myself while deep in the bush / outback hunting or camping, just to send a message to my wife. (a true EPIRB wouldn't be useful to let her know I'm all good, or ask her to call my mate to come pull my truck out of a bog hole)

I plan on sending short text messages via Morse Code, or probably just 8 bit ascii - so speed is not important. If a 50 character message takes 5 minutes to send - so be it... It's meant for check ins, not rapid messaging.

I'll take care of the screen and keyboard side of it - but just interested if anyone has any thoughts or experience using a long range AM signal generator like in the link, and interfacing an Arduino as a transceiver...

https://hackaday.com/2014/12/19/gibson-girl-emergency-beacon-built-from-a-wind-up-flashlight/


texts:
Hi everyone I am hoping someone here can help me.
I am trying to make an arduino turn my project on and off.Using a relay.
I am looking for it to act like a computer power button.
A short press to turn on and them stay on and a long press (say 5 sec) to turn off and then stay off till button is pressed again.
I would like it so that the project can not be accidentally turned off
Can anyone please help.
Thanks


texts: about how to write data in the whole EEprom?

texts:
I have interfaced AT24c1024 EEprom with ATmega32.AT24c1024, which has 512 pages each of 256 bytes. There are two mode of writing (byte write and page write).

In page write mode, it is capable of writing 256 bytes for page; if we want to write 258 bytes, then the first two bytes in the beginning of that page will be overwritten.

My question is: what should I do to write in the whole EEprom (i.e) if I want to write 300 bytes, I want to writes 256 bytes in a page then continues to the next page and so on?


texts: RF24Mesh master-base node communication delay

texts:
I'm trying to build a mesh network using 4 nRF24L01 modules directly connected with Arduino Uno where 1 module is master node and the rest are base nodes.

The workflow is exactly as follows

I'm sending a command in the Arduino IDE serial monitor. The master node receives this command and send it to other base nodes. There's no problem receiving the command on the base node side (from master node) as well as sending the command on the master node side (to base nodes). Upon receiving the command from the master node, base nodes successfully able to read the command and send the response. No problem at all.

But when the master node receives the response status from the base node(s), there's the problem. Master node is not receiving the data immediately. I have to send the command from the Arduino serial monitor repeatedly and on the 10th time, the master node is able to read the response status from the base node(s). Exactly on the 10th times every time.

Here's the source.

master node

// global variables
int dat2;
String temp1 = "";
boolean actualDataSent = false;

// get input from arduino serial monitor

 while (Serial.available() > 0) {
      // my command
      String temp1 = Serial.readString();
}

// write block
if (actualDataSent == false && temp1 != "") {

    // send this data to the base node one by one char
    for (int j = 0; j < mesh.addrListTop; j++)
    {
      for (int k = 0; k < temp1.length(); k++) {
        char ch = (char)temp1.charAt(k);
        Serial.print("NodeID: ");
        Serial.print(mesh.addrList[j].nodeID);
        Serial.print(" RF24Network Address: 0");
        Serial.println(mesh.addrList[j].address, OCT);
        RF24NetworkHeader header(mesh.addrList[j].address, OCT);
        Serial.println( network.write(header, &ch, sizeof(ch)) == 1 ? F("Send OK") : F("Send Fail"));
      }
      actualDataSent = true;
    }
    temp1 = "";
  }

// read block
else if (network.available() && actualDataSent == true) {
    RF24NetworkHeader header;
    network.peek(header);

    switch (header.type) {
      case 'M':
        network.read(header, &dat2, sizeof(dat2));
        Serial.print("Got: ");
        Serial.print(dat2);
        Serial.print(" from RF24Network address 0");
        Serial.println(header.from_node, OCT);
        actualDataSent = false;
        break;
      default: network.read(header, 0, 0); Serial.print("Not M case"); Serial.println(header.type); actualDataSent = false; break;
    }
  }

base node:

//global variables

String mypayload = "";
int res1;

// receive command from master
while (network.available()) {
    RF24NetworkHeader header;
    network.read(header, &payload, sizeof(payload));
    mypayload.concat(payload);
  }
  if (mypayload != "")
  {
    Serial.print("Received data: ");
    Serial.println(mypayload);
    if ((mypayload == "100%"))
    {
      res1 = 1;
      Serial.println("Turn ON");
      if (!mesh.write(&res1, 'M', sizeof(res1))) {
      if ( ! mesh.checkConnection() ) {
        Serial.println("Renewing Address");
        mesh.renewAddress();
      } else {
        Serial.println("Send fail, Test OK");
      }
    } else {
      Serial.print("Send OK: "); Serial.println(res1);
    }
    }
    else if (mypayload == "0%")
    {
      res1 = '1';
      Serial.println("Turn OFF");
      if (!mesh.write(&res1, 'M', sizeof(res1))) {
      if ( ! mesh.checkConnection() ) {
        Serial.println("Renewing Address");
        mesh.renewAddress();
      } else {
        Serial.println("Send fail, Test OK");
      }
    } else {
      Serial.print("Send OK: "); Serial.println(res1);
    }
    }
    mypayload = "";
  }


texts: LCD screen suddenly displaying and updating inaccurately

texts:
For the final project of my Arduino course, I have decided to make an alarm clock. The actual clock part was easy enough, but when I wired my buttons up, I accidentally loosened a few wires that a classmate with an identical kit helped me wire up. And although that is resolved now, the halves of my screen are flipped and the second ticker is now only updating every 5 seconds with the same code, even when I comment out unrelated code and reupload. I triple checked the wiring and moving wires around didn't do much either, so I have no idea what is causing this glitch, but hope one of you guys can help me figure it out. Here are some images for reference: https://imgur.com/a/zBUQgkz and my code is below:

#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
/*
 * VSS: GND
 * VDD: 5v
 * V0: Potentiometer
 * RS: D1
 * RW: GND
 * E: D2
 * D4: D4
 * D5: D5
 * D6: D6
 * D7: D7
 * A: 5v
 * K: GN/>
 */

//Variables to make the time work
int hour = 11;
int minute = 59;
int second = 40;
int flag = 1;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true);
  lcd.begin(16, 2); // initialize lcd width width and height
  lcd.clear();
}
void loop() {
// Print the time and make sure there are always 2 digits
    lcd.setCursor(0,0);
    if (hour < 10)
      lcd.print ("0");
    lcd.print(hour);
  lcd.setCursor(2,0);
    lcd.print(":");
  lcd.setCursor(3,0);
    if (minute < 10)
      lcd.print ("0");
    lcd.print(minute);
  lcd.setCursor(5,0);
    lcd.print(".");
  lcd.setCursor(6,0);
  if (second < 10)
    lcd.print ("0");
  lcd.print (second);
  lcd.setCursor(10,0);
    if (flag == 0)
      lcd.print ("AM");
    if (flag == 1)
      lcd.print ("PM");
}```


texts: Blynk, but continue program if Blynk connection fails

texts:
I'm having an issue with Blynk.begin(auth, ssid, pass);
The problem is, when it fails to connect to the wifi, the rest of the program does not continue.
I'm using a Wemos D1 and it is also controlling some relays based on a temperature sensor.
But when there was a power outage and power comes back on, the programs should continue whether the wifi is working or not, so that relays can still be controlled by the temperature sensor reading.
What happens now is if there is a wifi issue when Wemos D1 is starting up again, the program simply stops in the void setup() at Blynk.begin(auth, ssid, pass); and the rest of the program cannot be executed.
Anyone knows how to avoid this?
Kind regards,
Peter


texts: Arduino stops logging data after ~32761 seconds

texts:
I made a small set up to log temperature on SD card, everything is running smoothly until it reach 9:06:01 of logging that is  32761 seconds. I know that corresponds roughly to the maximum value of an integer. But I made all my variables unsigned long.
Here is the code in the loop and the if condition to log or not. The timer is computed with currentTime (unsigned long) and startTime (unsigned long). So even if logCount*freq are both integers, they should reach maximum value after 32761 seconds, then the if condition should always be true.

void loop() {
 String date;
 unsigned long timer;
 int freq = 60;

 sensors.requestTemperatures();
 tempC1 = printTemperature(insideThermometer, 18);
 tempC2 = printTemperature(outsideThermometer, 19);

 // start serial port
 Serial.begin(9600);

 mainMenuDraw();
 operateMainMenu();

 CurrentTime = millis();
 timer=(CurrentTime - StartTime)/1000;
 date = TimeShowFormatted(CurrentTime - StartTime);

 if (timer > logCount * freq and StopStatus == 0) {
  logCount += 1;
  LastLoggedDate=date;
  DataLogg(date);

 }
}


texts: esp8266 esp-01 crashing, restarting over and over

texts:
I flashed my ESP-01 with the nodemcu firmware 512k version, and everything was working fine.  I testing some lua scripting on init.lua and it was working.  Then, after writing a bunch of code and uploading, the module restarted.  And it restarted.  And it's still restarting, over and over again, and prints to serial

CÀbc0°ýbcü¨HøNodeMcu 0.9.4 build 20141230  powered by Lua 5.1.4
ö,3bþÈH

It was always printing the garbage in there before, so I'm not worried about that.  However, I can't send anything to the device--I can't send serial commands, or reflash the device.  I'm thinking I overloaded the memory or something.  Anyone have any ideas for recovering this brick?


texts: Change the fuses of an Arduino Uno (can an Arduino Uno change its own fuses?)

texts:
For now, I'm using an Arduino Uno alone including its 328p (no other external chip to program).

I would like to change its fuses to internal 8 Mhz clock (because then I'll move the 328p out of the Arduino Uno), and for simplicity I'd like to do it from Arduino IDE.

Here is what I tried:

I created a new entry in boards.txt copy-pasted from Uno, fuses modified, like this:

atmega328p.name=Atmega328p
atmega328p.upload.tool=avrdude
atmega328p.upload.protocol=arduino
atmega328p.upload.maximum_size=32256
atmega328p.upload.maximum_data_size=2048
atmega328p.upload.speed=115200

atmega328p.bootloader.tool=avrdude
atmega328p.bootloader.low_fuses=0x62
atmega328p.bootloader.high_fuses=0xD9
atmega328p.bootloader.extended_fuses=0xFF
atmega328p.bootloader.unlock_bits=0x3F
atmega328p.bootloader.lock_bits=0x0F
atmega328p.bootloader.file=optiboot/optiboot_atmega328.hex

atmega328p.build.mcu=atmega328p
atmega328p.build.f_cpu=8000000L
atmega328p.build.board=AVR_UNO
atmega328p.build.core=arduino
atmega328p.build.variant=standard

I selected this board in Tools > Board: Atmega328p
I tried to Upload any sketch (and not Upload with programmer since I have no other chip connected to the Arduino Uno), hoping it would modify the fuses during the (successful) Upload process.

I think it didn't work (when I move the 328p outside of the Uno it doesn't work).

How can I change the fuses for an Arduino Uno directly from Arduino IDE, to enable internal 8 Mhz clock?

PS: "Tools > Burn Bootloader" does not succeed, but I think this is normal, since there is just the Arduino Uno, and no other chip / nothing to use as a "Programmer":

  avrdude: stk500_recv(): programmer is not responding
  avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03


texts:
I'm having an issue trying to use a normal non-member function of my main sketch file as a callback.  I can't get the function pointer to invoke from a function other than it was saved.  More info below;

MotorEncoder.h

typedef void (*cb)(int16_t,int16_t);
class MotorEncoder
  ...
  private:
    cb _motor_callback;

Program.ino

cb encoder_cb = NULL;
...
encoder_cb = function_that_accepts_2_int16
DC_Encoder_1.move(motor_pos, speed, motor_id, encoder_cb);

EDIT: I want to edit the description as to not confuse anyone.  The code with the callbacks above is all correct.  The issue was I was working with open-source software and another developer was setting the selected serial-port connection back to the bluetooth channel in-correctly.  The callback was executed, I was connected to the ATMega2560 via serial connection to a raspberry pi and was looking for the callback to show there, not monitoring bluetooth so I didn't see any data come across.  Document your code.


texts: How to assign ESP8266 access point a hostname that can be resolved by the stations?

texts:
I want to assign a hostname to a ESP8266 access point, so that the clients can reach a webserver on this access point without caring about the IP address of the AP. How can that be done?
I tried using WiFi.hostname("something"); but that does not work with AP mode. Can this somehow be done?
UPDATE
Using mDNS seems to work in this AP mode too. However, I am still curious to know if this is possible to access the webserver on the AP using the hostname and not mDNS.


texts: Initiating 2nd I2C bus on ESP32 with CCS811 sensor

texts:
I want to connect two CCS811 sensors with ESP32 dev board. Since the sensors have fixed address, I am unable to use them simultaneously. I have read that on ESP32 multiple I2C buses can be created. While trying to follow that route I tried to modify the library but I am stuck. I can't simply pass different pins for SDA and SCL when calling ccs.begin() function. It only takes one argument and that is the sensor address (code chunk from library below):
bool Adafruit_CCS811::begin(uint8_t addr) {
  _i2caddr = addr;

  _i2c_init();

  SWReset();
  delay(100);

  // check that the HW id is correct
  if (this->read8(CCS811_HW_ID) != CCS811_HW_ID_CODE)
    return false;

  // try to start the app
  this->write(CCS811_BOOTLOADER_APP_START, NULL, 0);
  delay(100);

and the actual wire.begin() function is called in the _i2c_init() function which is defined in the lib as:
void Adafruit_CCS811::_i2c_init() {
  Wire.begin();
#ifdef ESP8266
  Wire.setClockStretchLimit(500);
#endif
}

With my very basic knowledge of classes and object, I am unable to modify the library to make it work with 2 I2C buses. Could you please help me with this?
Link to Adafruit CCS811 library:(https://github.com/adafruit/Adafruit_CCS811/blob/master/Adafruit_CCS811.cpp)
My Code so far:
#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_CCS811.h"

Adafruit_CCS811 ccs1;
Adafruit_CCS811 ccs2;

TwoWire sen1 = TwoWire(0);
TwoWire sen2 = TwoWire(1);

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

  Serial.println(F("CCS811 test"));

  if (!ccs1.begin(25, 26, 100000))
  {
    Serial.println("CCS 1 Failed.");
    //while (1);
  } else {
    Serial.println("CCS 1 OK!");
  }

  // Wait for the sensor to be ready
  //while (!ccs.available());
}

void loop()
{
  if (ccs1.available())
  {
    if (!ccs1.readData())
    {
      Serial.println(" This is CSS");
      Serial.print("CO2: ");
      Serial.print(ccs1.geteCO2());
      Serial.print("ppm, TVOC: ");
      Serial.println(ccs1.getTVOC());
    }
    else
    {
      Serial.println("ERROR!");
      //while (1);
    }
  }
  delay(500);
}


texts: where to get Arduino WIFO101 library that supports WiFi.beginAP() on board MKR1000

texts:
The sketch example from page "Wifi.beginAP()" causes compiler error because the return values are not defined for -WL_AP_LISTENING or -WL_CONNECT_FAILED.

Board: Arduino MKR1000 WiFi

Compiler:  Arduino IDE

Library: Github WiFi101 v0.9.1

Missing:  definition of "WL_AP_LISTENING" and "WL_CONNECT_FAILED"

ERROR....
beginAP.ino: In function 'void setup()':

beginAP:55: error: 'WL_AP_LISTENING' was not declared in this scope

if (status != WL_AP_LISTENING) {

              ^

Arduino WiFi101-MKS1000 examples\beginAP\beginAP.ino: In function 'void loop()':

beginAP:78: error: 'WL_AP_CONNECTED' was not declared in this scope

  if (status == WL_AP_CONNECTED) {

                ^

exit status 1
'WL_AP_LISTENING' was not declared in this scope


texts: Detect certain audio ques with a microcontroller

texts: Hey I had a random idea which is... A microcontroller or raspberry pi that can listen to the the audio ques produced by a game to alert you of things that you might have missed... Could you guys possibly lead me down the right path as to where I can find more information about this...


texts:
I am looking for an example of how to load a program from sd card to SRAM and execute it from there on the SAMD21.

I understand that the given MCU use the Von Neumann architecture and all code is privileged.


texts: MATLAB - Read from 2 SPI inputs synchronously

texts:
I am using the MATLAB Arduino Support Package to create a setup where I can read force data from a load cell and positional data from an incremental encoder - then plot them on MATLAB. It must be done at the same time in order to produce a material stress-strain curve.

I am thinking of using the SPI Device functions to do this.

Can the data from the load cell and encoder be read synchronously?


texts:
I have made this small program to lighten up in sequence 8 LEDs, it starts fine, but it stops working after a minute or so and the first 2 LEDs stay permanently ON, its like the chip stoped, here is the code :

// Initialize an array with all 8 leds
// and give them the corresponding
// digital number.
const byte led[8] = {0,1,2,3,4,5,6,7};

// the setup routine runs once when you press reset:
void setup() {

  // initialize all 8 digital I/O pins as outputs.
  for (byte i = 0; i<9; i++) {
    pinMode(led[i], OUTPUT);
  }
  pinMode(13, OUTPUT);
}

void left (void);
void right (void);

// the loop routine runs over and over again forever:
void loop() {

  right();
  left();

}

void left (void) {
  for (byte i = 0; i<9; i++) {
    digitalWrite(led[i], HIGH);
    delay(50);
    digitalWrite(led[i], LOW);
  }
}

void right (void) {
  for (byte i = 8; i>0; i--) {
    digitalWrite(led[i], HIGH);
    delay(50);
    digitalWrite(led[i], LOW);
  }
}

I am using a very old arduino duemilanove.


texts: ESP32 HTTP Server request interrupts Telnet session

texts:
I have an ESP32 application that uses a web server as a user interface. For auditing and debugging during development I use Serial; however, that is impractical in the installed system. So, I decided to use Telnet (TCP/IP) to monitor what is happening when Serial is impractical.
The issue is that once a TCP/IP session has been established, when a HTTP request is received, the TCP/IP session is aborted.
I have reproduced the issue in a minimal sketch here:
#include "Arduino.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>

WiFiClient telnetClient;
WebServer server(80);
WiFiServer telnetServer(23);

void telnetPrint(const char* text)
{
  if (telnetClient)
  {
    telnetClient.print(text);
  }
}

void telnetPrintln(const char *text)
{
  telnetPrint(text);
  telnetPrint("\r\n");
}

void _print(const char* text)
{
  Serial.print(text);
  telnetPrint(text);
}

void _println(const char* text)
{
  Serial.println(text);
  telnetPrintln(text);
}

void _println(IPAddress myIP)
{
  char rgIPTxt[32];
  sprintf(rgIPTxt,"%u.%u.%u.%u",myIP[0],myIP[1],myIP[2],myIP[3]);
  _println(rgIPTxt);
}

const char *rootFmt="\
\
  \
    <title>Test</title>\
  \
  \

Test
\

\

Heap size=%d

\

\
  \
\
";

char rootMessage[1024];

void updateRootMessage()
{
  _println("updateRoot");
  snprintf(rootMessage, sizeof(rootMessage), rootFmt,
           heap_caps_get_free_size(MALLOC_CAP_8BIT)
           );
}

void handleRoot()
{
  _println("Entered handleRoot");
  updateRootMessage();
  server.send(200, "text/html", rootMessage);
  _println("Leaving handleRoot");
}

void wifiSTASetup(const char*ssid, const char*password)
{
  WiFi.mode(WIFI_AP_STA);
  WiFi.begin(ssid, password);
  telnetServer.begin();
  telnetClient=telnetServer.available();
  _println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    _print(".");
  }
  _println("");
  _print("Connected to ");
  _println(ssid);
  _print("IP address: ");
  _println(WiFi.localIP());
  server.on("/", handleRoot);
  server.begin();
}

#define BAND    915E6

void setup()
{
  Serial.begin(115200);
  wifiSTASetup("your ssid", "your password");
}

void loop()
{
  server.handleClient();
  if (!telnetClient)
  {
    telnetClient=telnetServer.available();
    if (telnetClient)
    {
      _println("telnetClient obtained");
    }
  }

}


texts:
I am running my arduino project with the atmega328 chip like this:

I have purchased by mistake this crystal:

The reason why I purchased by mistake that crystal was because it has this description:

  16MHz ±10ppm 22pF 60Ω SMD-3225 SMD Crystal Resonators RoHS

I thought that it contained the 22pF ceramic capacitors inside. But latter I learned that I still the 22pf ceramic capacitors. (Please correct me if I am wrong)

Anyways how can I use that crystal? I only know how to connect the 2 pin crystal. Since this crystal has 4 pins now I am confused.

To me it makes sense to connect it like this:

Connect pins 9 and 10 from atmega --TO--> pins 1 and 3 from the crystal.
Connect pins 2 and 4 from crystal --TO--> Ground
Connect the 22pf ceramic capacitors to pins 1 and 3 from crystal and ground like in the first diagram.


texts: Sublime as external editor, error on Arduino compile dropdown: "avr-g++ is not recognized...", from Stino

texts:
The error message, generated from Sublime, in its entirety...

Compiling KCT_Swimv4l...

Creating C:\Users\ken\Documents\Arduino_Build\KCT_Swimv4l\KCT_Swimv4l.ino.cpp.o...

'"avr-g++"' is not recognized as an internal or external command,
operable program or batch file.

[Stino - Error 1]

This is initial install of "Arduino-like IDE".

I used the following installation procedure:

Install Sublime Text 3
From Sublime, View --> Show Console
From a web browser, open  https://sublime.wbond.net/installation and choose Sublime Text 3 version.
Copy the code there to the Sublime-Console and press enter.
From Sublime, CTRL + Shift + P --> Type "Install" and choose "Install package"
Enter "Arduino" and choose "Arduino-like IDE"
from Arduino --> Preferences --> Select Arduino Application Folder.

Same problem with any sketch.

System Configuration:

-Windows 10 x64, current level
-Sublime Text 3 x64, build 3126
-Arduino IDE 1.8.0

github info on Stino was not helpful.
Has anyone encountered this problem and found a solution for it?
If not, I can open an issue there.

I have now done the following:
Uninstalled Sublime
Searched System drive and removed any remaining Sublime content
Searched System drive and removed any Stino content
Download WinAVR from http://winavr.sourceforge.net/download.html, selecting PATH option
Reinstalled Sublime Text 3 x64
Close & Reopen Sublime
From Sublime, View --> Show Console
From web browser, open https://sublime.wbond.net/installation and choose Sublime Text 3 version.
Copy the code there to the Sublime-Console and press enter
Close & Reopen Sublime
From Sublime, CTRL + Shift + P --> Type "Install" and choose "Install package"
Enter "Arduino" and choose "Arduino-like IDE"
Close & Reopen Sublime
From Arduino --> Preferences --> Select Arduino Application Folder

On Compile, error msg is now different:
  Compiling KCT_Swimv4l...
  Creating C:\Users\kct\Documents\Arduino_Build\KCT_Swimv4l\KCT_Swimv4l.ino.cpp.o...
  cc1plus.exe: error: unrecognized command line option "-std=gnu++11"
  cc1plus.exe: error: unrecognized command line option "-flto"
  [Stino - Error 1]


texts:
I want to use my Arduino Nano to control a 12V peristaltic pump via a BDX33c N-Channel MOSFET. The pump has a maximum current draw of 1,4 A. The Arduino (via VIN) and the pump are powered by a 12V supply. I connected the parts like shown in the schematic diagram.

When I plugged the supply in, the Arduino voltage regulator and the Mosfet got really hot (I could not touch it longer than 1-2 seconds) and the RX-LED was on continously, even after turning it off and on again. The Arduino isn't recognized by my Computer anymore, so I assume it is dead.
What did I do wrong with my wiring?


texts:
2days back I opened my cousin brothers laptop battery as it was a spare one left unused over a year.
I disintegrated it and found 6x 18650 batteries when I checked them with voltmeter individually I found that 2 were dead I.e.0V and 2 read 2.15 V and the last two read 1.5V. I thought of making a power bank using them individually. The battery are ideal for a power bank because they have 2200ah capacity. I need a circuit to charge it. I thought of chraging it with arduino. But how?
To get the datasheet just search "lr1865ah" in google and click the one and only pdf link that is the cell's datasheet. I need the charing circuit using arduino.


texts: There is any way to simulate an arduino due?

texts: As the title says there is any program that can simulate an arduino due? I like the design of Proteus 8 but he can't simulate it. Only the arduino Uno R3, Mega and another one that I forgot the name.


texts:
in my arduino project I use the Adafruit CCS811 Air Quality Sensor Breakout - VOC and eCO2, I need the references and sizes of these components, knowing that I have found the electrical diagram but the values and references are not clear as you see in the photo.
Link to the sensor: https://learn.adafruit.com/adafruit-ccs811-air-quality-sensor/overview
Thank you in advance for your help.


texts: Curious: What would happen if you connect 5V and GND port directly with a wire

texts:
Has anyone ever accidentally or inadvertently connected connected the supply port with the ground port with a wire?

Does Arduino provide internal safety to prevent the circuit board from shorting out?


texts: Why does my type K thermocouple have blue and red wires?

texts:
I recently purchased a type K thermocouple for use with an Arduino. Based on what I read everywhere, type K thermocouples' wire colors should be yellow (+) and red (-), by standard. However, what I see on the web (e.g., Amazon) is type K thermocouples with red and blue wires. Even when I look at international color standards for thermocouples, I don't see blue+red anywhere for type K thermocouples.

Does anyone know why the type K thermocouples available for purchase don't follow what is supposed to be the standard for wire colors?
With the red+blue wiring, is blue the positive wire and red the negative wire?

Thanks!


texts: Where can I find beginner resources on using voltage regulators with Arduino circuits?

texts:
I'm trying to concurrently learn electronics and Arduino, and have recently moved from simply powering LEDs to servos. In all my attempts with servos and reading about them (especially multiple ones, and when using external power supply plugged into the board), experienced users often mention you use voltage regulators.

I've seen some Arduino schematics with servos and voltage regulators, most that include some capacitors, but I can't seem to find any tutorials or resources that explain why, when and how to use these parts when learning electronics & Arduino. (I'd like to go from there to transistors, mosfets, etc.)


texts: Using SoftwareSerial along with FastLED library to control WS2812 LEDs

texts:
I am controlling WS2812 LEDs with Arduino nano using FastLED library. I want the LED patterns to change on receiving a command from another Arduino Nano over software serial, I don't have the option to use he hardware serial.

I have read that in order to write data to LEDs, the library disables all the interrupts. However the SoftwareSerial library also uses interrupts to transmit data properly. Is there any possible way to achieve this? Presently, when I am trying to do this I am getting garbage data.


texts:
I have a following code

  #include <Servo.h> //library for servo drive
  int MotorAPinA = 9;   //pin number for DC drive
  int MotorAPinB = 10;  //pin number for DC drive
  Servo myservo; //create object myservo, class servo from Servo library

void setup() {
  // put your setup code here, to run once:
  pinMode(MotorAPinA, OUTPUT);
  pinMode(MotorAPinB, OUTPUT);
  //myservo.attach(6); //pin number for servo output
  myservo.write(65);
}

void loop() {
  analogWrite(MotorAPinA, 240);
}

This very code works only partly.
If I comment line

myservo.attach(6)

then I got my DC drive working.
If I uncomment this line, my Servo goings crazy (effect looks like myservo.write(0) constantly), until I comment line

analogWrite(MotorAPinA, 240);

and then I got my servo working properly.
While myservo.attach(6) is uncommented, DC drive doesn't work (with uncommented analogWrite).

So, basically, I can have or PWM or Servo working simultaneously, but not both

Any ideas? Arduino Uno R3, Arduino 1.8.1.


texts: DS3218MG Servo - Not working with power supply

texts:
I'm trying to run my DS3218MG Servo Motor with an external power supply and my arduino nano.
I'm using the following code:
#include<Servo.h>
Servo Myservo;
int pos;
void setup()
{
Myservo.attach(3);
}

void loop()
{

for(pos=0;pos<=180;pos++){
Myservo.write(pos);
delay(15);
}
  delay(1000);

  for(pos=180;pos>=0;pos--){
Myservo.write(pos);
delay(15);
}
  delay(1000);

}
According to the datasheet the servo needs a DC 4.8-6.8 voltage. My first attempt was to only use the arduino and no external power supply. So did the following connections:

servo's ground to arduino's ground
servo's + to arduino's 5V
servo's data to arduino's GPIO pin 3

Using this connection works fine and the servo rotatates to the desired positions. However, because the arduino does not supply enough current, i bought a power supply with the following specs:

With that, i did the following connections:

connect the ground of the power supply to arduino's ground (and servo)
keep the data pin
connect + of power supply to servo's +

Unfortunately, the servo does not move with the external power supply. IMO, it should have the right voltage and also supply enough current (at least as much as the Arduino).
Do you see the problem?


texts: Can tx and rx pins on the uno be used like regular digital pins?

texts:
The uno has digital pins marked 0-13.

0 is marked as rx and 1 is marked as tx.
Can these two pins be used as regular digital pins if i am short of digital pins?


texts: Signal pin of buzzer is connected with which Arduino uno pin

texts:
I bought a 3 pin buzzer. It has positive, negative and signal pin.

I don't understand how this signal pin should be connected with the Arduino.

Here is reported the description page of the buzzer.


texts: Addressing contents of array using incrementing variable

texts:
Why would this simple code which prints out array values give the right value 240 when the array is addressed with index directly addressed by number
but give 184 when addressed usin a varibale n that is incrementing?

PROGMEM const unsigned char COLSA[8] = {
      240, 240, 240, 240,
      240, 240, 240, 240};  //Stored pattern

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

void loop() {
  int n;
   for(n=0;n<8;n=n+1)
    {
      Serial.println(n);
      Serial.println(COLSA[1]);
      //n=2;  //If I use n in this way things are fine. It prints 240. Else it prints 184
      Serial.println(COLSA[n]);
    }
     delay(100);
}


texts:
is there a way to use a previous assigned value to variable to adjust the step motor? what i mean is:

example:
Sensor reads 100 degrees so

Adjust the step motor to 100 degrees and hold, then after 10 min

the sensor reads 110 degrees so

Adjust the step motor (110 - 100) by extra 10 degrees

and so on..

I'm really new to this and i'm sorry if that's a stupid question :<


texts:
I have a project in Microsoft Visual Studio C# and I have to pass JSON data to my Arduino via Ehternet Shield.

This is how it works:

Is it possible? How to do it?


texts:
I try to send an "a" string via serial with

Serial.println("a");

and I receive "Oy=" in Ascii or {4F}{79}{3D} in Hexa.

Where should I start investigating? What could be wrong?  Baudrate is 9600 on all sides.

PS: I suspect the cable. Any hints how to check it?


texts:
I have a strange problem with the MAX31865 and the PT100. Every time when I start the system it shows that the temperature is -242 and the RTD value is 0 and so on.
But When the system is in the loop() and when I unplug the power cable of the MAX31865 and put it back on, it shows the right temperature. The same happens when I start the serial monitor.


texts: How to measure relay current draw from Arduino

texts:
How does one measure the amount of current a relay is drawing from an Arduino?

Do I connect a multimeter in series with the digital pin to which the relay 'IN1' is connected (in this case pin 7), the 5V pin or GND pin?

Provisional testing gives me the following results (when the relay is ON):

Pin 7: 3.93 mA
5V pin: 70.2 mA
GND pin: 66.8 mA

Also, assuming I pull more than 40 mA through digital pin 7 for a number of seconds, is the pin likely to fail immediately? Or slowly degrade over time?


texts:
How would I safely connect an Arduino so that it can detect if a laptop is on or off?

The Arduino would be powered separately by a normal USB charger, since it needs to be turned on even when the laptop is turned off. So I'm thinking I can connect an input on the Arduino to one of the USB ports on the laptop somehow, but how do I do this safely?

Even if I play it safe and connect a current-limiting resistor between the USB voltage and input pin, and perhaps a voltage divider, is there still a problem with connecting one device to another like this? I'm thinking that since each has its own power supply from mains, could there potentially be a problem if I connect the USB port of the laptop to a pin on the Arduino?

Do need to use an optocoupler or relay between them? Or is there an even better way of doing this that I didn't think of?


texts:
I have built the circuit below using mux ICs. In a particular interval the respective selector pins get selected and analog signal from hall sensors are read and give a particular analog value out. There is a total of 30 hall sensors which are represented by HS0 to HS31.

Now I wanted to set time as in the table below. After 8000ms I would like it to reset the time automatically and start reading. Can someone tell me which timer example would let me achieve this?

TIME IS ms  OUT1    OUT2    OUT3    OUT4
  0-1000    HS0     HS8     HS16    HS24
1000-2000   HS1     HS9     HS17    HS25
2000-3000   HS2     HS10    HS18    HS26
3000-4000   HS3     HS11    HS19    HS27
4000-5000   HS4     HS12    HS20    HS28
5000-6000   HS5     HS13    HS21    HS29
6000-7000   HS6     HS14    HS22    HS30
7000-8000   HS7     HS15    HS23    HS31


texts: USB Device not recognized (error 43, arduino uno)

texts:
I know that there's already post about this, but mine is different. Instead of not recognized, it gets recognized, and I can upload codes, but after a while, windows starts to not recognize it. And there is a temporary fix for this for my laptop, I need to restart. And even after restarting, it still becomes not recognized after a while

Edit : forgot to mention, even if it is not recognized, it still sends power to the arduino


texts:
I'm trying to convert a class header file from another c++ project to arduino, which in my mind involves replacing cout with Serial.println.

When I try to recomplile with all of these changes, I get this error from the compiler:

error: 'Serial' was not declared in this scope
     Serial.print(p[i]);

Can someone explain this to me?


texts:
I am trying to print QRcode (not bitmap) on my thermal printer with Arduino and ESP32.

I am using the same QRcode library and Adafruit Thermal printer library of this post.

How to scale a bitmap (uint8_t array) in Arduino?

Is it possible to convert the pixel coordinates + color to a bitmap or print the pixel(x,y, color)?

Thanks for all

I need some code to print a QRcode. I am using this code to my oled display.

static uint8_t buffer[QR_VERSION_BUFFER_SIZE(7)] = { 0 };

QRCode qrcode = { 0 };
const int8_t error = qrcode_initText(&qrcode, buffer, 7, 0, "1245");
ASSERT_DEBUG_MODE(0 == error);

const uint8_t y0 = 10;
const uint8_t x0 = 10;

for (uint8_t y = 0; y < qrcode.size; y++)
{
    for (uint8_t x = 0; x < qrcode.size; x++)
    {
        uint8_t pixel = 0;
        if(qrcode_getModule(&qrcode, x, y) )
        {
            /*Put black pixel*/
            pixel = 0;
        }
        else
        {
            /*White pixel*/
            pixel = 1;
        }

        HI_GFX_Draw_Pixel(x0 + x, y0 + y, pixel);

    }

}


texts: Custom ATMega 2560 board won't execute Arduino code

texts:
I have a custom PCB with an ATMega 2560 microcontroller on it. To test if the ATMega was working properly, I uploaded the following code:

void setup() {
  Serial.begin(9600);
  Serial.println("Test setup");
  pinMode(6, OUTPUT);
  pinMode(30, OUTPUT);
  pinMode(31, OUTPUT);
  pinMode(32, OUTPUT);
}

void loop() {
  digitalWrite(6, HIGH);
  digitalWrite(30, HIGH);
  digitalWrite(31, LOW);
  digitalWrite(32, HIGH);
}

The mentioned ports are connected to LEDs, 6 to an external LED and 30, 31 and 32 to LEDs on the PCB. Each connected in series with a 220 Ohm resistor.

The board is setup like this:

When uploading I am using a Arduino UNO as ISP and after uploading the Arduino IDE says 'Done uploading' without any errors, but the board is not showing any sign of executing the code. I have checked that VCC is 5V and RESET is HIGH after uploading. The text "Test setup" is also not shown on the serial monitor.

Does anybody have a clue why the board is not working?

Thanks on forehand.


texts: Coin Recognition from Parallel Coin acceptor to Arduino

texts:
I have one project to do where I have one big problem and I need your help. At this stage, it is not a problem for me to write Arduino program for a money receiver who has an impulse output. But the coin receivers that have a parallel output lines which is described in the manuals in detail how it comes to information in the cables of the coin drop, but I can not hit on a decision on how to program Arduino to know coin type, I hope you any of you have a similar experience and will be able indicating which way to raise in order to get to work this project. Coin model is:

EMP 800 v6
Link to the manual

Any your suggestions may be the my life saver...
Thank you in advance guys...


texts:
Hello I have an Arduino programme that has a string with the words hello in it.
I can add characters and other strings to the end of that one using:

   String test = "hello";
   test+=" jack";

it would then say "hello jack"
The problem is I want to get rid of the last character of the string every 2 seconds so it would be "hello jac" then "hello ja" and so on. How can I do this?


texts:
I should begin by saying I am not a programmer, do not really know much about programming, and am programming an Arduino Uno for the first time. I am using a Nema 23 motor (23HS22-2804S) with a microstep driver (ST-M5045). Within the following code is the description of what I need the program to do:
#include <AccelStepper.h>

/* Using a stepper motor,
 rotate a vibrational model using gears interconnected by springs
 in such a way as to induce torsional vibration, which should be visible by comparing
 movement of juxtaposed rotating gears with markers painted on. */

AccelStepper stepper(AccelStepper::FULL4WIRE, 2, 6, 4, 8);

int Microstepping = 8; /* Microstepping factor, as set on the ST-M5045 control board.
                          Multiplies the number of steps per revolution on the stepper motor.
                          Reference controller manual for adjustments to this number. */
int Steps = 200; /* Number of steps on your stepper motor.*/
int SPS;
int Amp;
int Freq;
// int SC;
int n = 2;
int i;
int totalSteps = Microstepping * Steps;

/* It should be noted that the Microstepping and Steps factors are not necessary, and adjusting the microstepping factor
 *  on the fly will not break the code. However, be aware that changing the microstepping factor by more than one interval
 *  at a time can cause the motor to not keep up with the sudden changes, i.e. losing torque or vibrating/stuttering. */

void setup() {               // THIS RUNS ONCE //

  // read potentiometers; raw inputs from 0 to 1023 //
  SPS = analogRead(0)*0.733; // MAX RPM ~28, max speed ~750 steps per sec (speeds above 1000 steps per second are unreliable,
                             // according to AccelStepper documentation)//
  Amp = analogRead(1)/20;     // MAX AMP ~51//
  Freq = analogRead(2)/170;   // MAX FREQ ~6 Hz//

  stepper.setMaxSpeed(SPS);
  stepper.setAcceleration(SPS/1.5);

  int nextStop = totalSteps/Freq;

  stepper.moveTo(nextStop);
  stepper.run();
}

void loop() {
  int nextStop = totalSteps/Freq;

// reaches here, doesn't execute if loop.
   if(stepper.distanceToGo()== 0){
     SPS = analogRead(0)*0.733;
     Amp = analogRead(1)/20;
     Freq = analogRead(2)/170;
     i = SPS - Amp;
     if(i <=0)
       i = 1;
     stepper.setSpeed(i);
     stepper.moveTo(nextStop*n);
     stepper.run();
    }
    n++;
}

When I use Serial.println() to check where the program is working and where it isn't, I see that it completes the setup loop without ever moving, and in slightly different versions of the same code, it has entered the if() statement and executed it (also without moving.)
An earlier version of the program runs and executes all statements, but only moves a maximum of about 20 steps per second, without the fluctuations in speed I call for, and doesn't respond in real time to any input from the speed potentiometer that puts the speed above 20.
Ideally, the program would run the demo at full speed, and freq times per second, it would slow down just enough to be noticeable as a torsional vibration.
I have tried running the program with and without the run() lines, and I have tried using runToNewPosition() in attempts to get the program to stop and properly execute the movement.
I made the setup loop as close as possible to the setup loop in bounce.pde, the example program in the AccelStepper documentation which moves the stepper motor between two points repeatedly, accelerating and decelerating before changing directions. The reason I did this is because I know that the setup loop in bounce.pde works, and so I would feel more confident that my setup loop is not the root problem.
Any help you can offer me is appreciated! Thanks for your time.


texts: Operating HB100 backpack with Arduino Due

texts:
I need to connect a speed sensor module with an Arduino Due and calculate the speed of an approaching object.

the sensor is:
http://www.limpkin.fr/index.php?post/2013/08/09/Making-the-electronics-for-a-%247-USD-doppler-motion-sensor

The sensor already output a signal that its' frequency represents the speed of the object.

I would really appreciate any help understating how can it be connected and operated by the Arduino without burning it, and how can I sample its output?

If more details are needed I'll be happy to supply.

Thanks.


texts: Prevent hardware and library examples from showing in the Sketchbook menu

texts: I have various subdirectories in {SKETCHBOOK}/hardware/ and {SKETCHBOOK}/libraries/ that contain an examples/ subdirectory. These examples are showing up in File | Sketchbook | hardware and File | Sketchbook | libraries. Is there any way I can prevent them from showing up in that menu without moving them under the system-level Arduino directory?


texts: Arduino Sensor Values to Raspberry Pi using NRF24

texts:
Im trying to send temperature sensor data through NRF24L01 to Raspberry Pi and read it in Raspberry Pi using python. But the temperature sensor data comes to the Raspberry Pi as letters, which I found out is in Ascii values. Im not sure how to display the actual readings from the Arduino to the Raspberry Pi

Here is the Arduino code:

#include <DallasTemperature.h>
#include <OneWire.h>
#include <SPI.h>
#include <RF24.h>
#include "printf.h"
#define ONE_WIRE_BUS 2

OneWire oneWire (ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

RF24 radio(9, 10);

void setup(void) {

  Serial.begin(9600);
  sensors.begin();
  radio.begin() ;
  radio.setPALevel(RF24_PA_MAX) ;
  radio.setChannel(0x76) ;
  radio.openWritingPipe(0xF0F0F0F0E1LL) ;
  radio.enableDynamicPayloads() ;
  radio.powerUp() ;
}

void loop(void) {
  sensors.requestTemperatures();
  float temperature = sensors.getTempFByIndex(0);
  radio.write(&temperature, sizeof(float));
  delay(1000);
  Serial.print(sensors.getTempFByIndex(0));
}

Here is the code for Raspberry Pi in Python

from lib_nrf24 import NRF24
import time
import spidev

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
pipes = [[0xE8, 0xE8, 0xF0, 0xF0, 0xE1], [0xF0, 0xF0, 0xF0, 0xF0, 0xE1]]

radio = NRF24(GPIO, spidev.SpiDev())
radio.begin(0, 17)

radio.setPayloadSize(32)
radio.setChannel(0x76)
radio.setDataRate(NRF24.BR_1MBPS)
radio.setPALevel(NRF24.PA_MIN)

radio.setAutoAck(True)
radio.enableDynamicPayloads()
radio.enableAckPayload()

radio.openReadingPipe(1, pipes[1])
radio.printDetails()
radio.startListening()

while True:

    while not radio.available(0):
        time.sleep(1/100)

    receivedMessage = []
    radio.read(receivedMessage, radio.getDynamicPayloadSize())
    print("Received: {}".format(receivedMessage))

    print("Translating...")
    string = ""

    for n in receivedMessage:
        if (n >= 32 and n <= 126):
            string += chr(n)
    print("Our received message decodes to: {}".format(string))

I want to get the temperature value in numbers instead of letters. Instead of like this:

Translating ... Our received message decodes to: N


texts:
I wrote this little program to test converting and comparing 2 char with each other. With some help from here i have learned that you have to NULL-terminate c stings. But when i try to compare them i still get that they are not equal to each other. this is my program:

char code[4] = {'1','2','3','4'};
char strcode[5];
char pass[4] = {'1','2','3','4'};
char strpass[5];

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

void loop()
{
    memcpy(strcode, code, 5);
    strcode[4] = '\0';
    Serial.println(strcode);
    Serial.println("done");
    delay(1000);
    memcpy(strpass, pass, 5);
    strpass[4] = '\0';
    Serial.println(strpass);
    Serial.println("donepass");
    if (strpass == strcode)
    {
        Serial.println("yes");
    }
    else
    {
        Serial.println("no");
    }
}

I get this in my serial monitor:

1234
done
1234
donepass
no

Why is this not equal to each other?


texts: How do you extend the wires from the arduino board to both fsr sensors to be placed on both chairs (one for each)

texts:
I’m trying to figure out how to extend the wires for both force sensitive resistors so that it could be place on each chair, one sensor on one chair and the other sensor on the other chair

This is how this was originally connected

So what would be the best way to extend both cables to place both sensors on each chair


texts: How to convert uint8 to int for maths operation in Arduino?

texts:
I am receiving a string from my bluetooth terminal in uint8 format. I want to convert it to integer for further processing. How can I do this? I tried toInt() but it is not working. Please help.

Thanks in advance.


texts: Sending data from Arduino w/HM10 to relay board with hm12

texts:
It all started when I tried connecting an hm10-nano to a relay board which is Bluetooth enabled.  Here is my nano with the hm10 module:

And here is the relay board's BT module, which looks like an hm12:

I started by connecting the nano-hm10 to my mac and using the Arduino IDE to send the module commands.  The hm12 has a mac for ble and another for edr:

ble:00-0e-0b-00-75-12
edr:00-0e-0e-00-75-12

The hm10 does connect because:

I get a steady blue led on the hm10 after AT+COmacble
I get the macble from the hm10 module after AT+RADD?
I hear the relay (channel1) open on the relay board after AT+COmacble

When I try the following steps -> I get these results
1. Unplug relay board -> hm10 blue blinking
2. Plug relay board -> hm10 blue steady, relay BT module blue led steady
3. AT commands to hm10 thru serial monitor stop working (expected)
4. AT+CO000e0e007512 to hm10 -> turns on relay 1 for some reason
5. Unplug relay -> RADD on hm10 = 00-0e-0b-00-75-12 instead of 00-0e-0e-00-75-12

My questions are:
A. Is it possible to send data from an hm10 to hm12?
B. Why does the relay get activated when I connect to the hm12-relay board?
C. I just realized my sketch's bluetooth.print() sends a command from the nano to the hm10, not to from the hm10 to the hm12.  How can I send the data from the nano to the hm12?

Sketch:

#include <SoftwareSerial.h>
int bluetoothTx = 10;  // TX-O pin of bluetooth
int bluetoothRx = 11;  // RX-I pin of bluetooth
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup(){
  Serial.begin(9600);  // Begin the serial monitor at 9600bps
  delay(200);
  bluetooth.begin(9600);  // Start bluetooth serial at 9600
  Serial.print("send...");
  bluetooth.print("AT");
    bluetooth.print("110"); //open relay 1
    delay(2000);
  bluetooth.print("100"); //close relay 1
}
void loop(){
  if(bluetooth.available()){
    Serial.print((char)bluetooth.read());
  }
  if(Serial.available()){
    bluetooth.print((char)Serial.read());
  }
}


texts:
For a parking management system I am going to create an Arduino network.

An Arduino with an ultrasonic sensor will be placed above each parking space. If car is parked at specific location Arduino will inform master (PC) and also turn RED light ON.

I am not sure how I can make network with minimum wiring. I think RS485 will be suitable for this purpose.

There will be almost 200 Arduinos in a network. I have following questions in mind:

Should I go for RS485 protocol or something else?
Can RS485 support 200 devices as there will be only short communication (i.e device ID and parking status)?
I am planning to lay CAT6 cable. Two pairs will be used for power transmission and two pairs will be available for communication.


texts:
I want to make RFID Tag as a variable, and push it to the web server. But I struggle to do the Serial.read function.

Any solutions?

Here is my code

#include <ESP8266WiFi.h>
#include <SPI.h>
#include <MFRC522.h>

/* wiring the MFRC522 to ESP8266 (ESP-12)
SDA(SS) - D4 (GPIO2)
SCK - D5 (GPIO14) (hw spi)
MOSI - D7 (GPIO13) (hw spi)
MISO - D6 (GPIO12) (hw spi)
IRQ -
GND - G
RST - D3 (GPIO0) (FLASH)
3.3V - 3V
*/

#define RST_PIN D3 // RST-PIN für RC522 - RFID - SPI - Modul GPIO5
#define SS_PIN D4 // SDA-PIN für RC522 - RFID - SPI - Modul GPIO4

const char *ssid = "Keluarga"; // change according to your Network -
cannot be longer than 32 characters!
const char *pass = "batikpekalongan11"; // change according to your
Network

String a;

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
WiFiServer server(80);

void setup() {
Serial.begin(115200); // Initialize serial communications
delay(10);
Serial.print(F("Booting...."));

SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522

WiFi.begin(ssid, pass);

int retries = 0;
while ((WiFi.status() != WL_CONNECTED) && (retries < 10)) {
retries++;
delay(500);
Serial.print(".");
 }
if (WiFi.status() == WL_CONNECTED) {
Serial.println(F("WiFi connected"));
}

Serial.println(F("Ready!"));
Serial.println(F("Scan for Card and print UID:"));
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

// Start the server
server.begin();
Serial.println("Server started");
  }

void loop() {
 // Check if a client has connected
 WiFiClient client = server.available();
 if (!client) {
 return;
 }

 // Look for new cards
   if ( ! mfrc522.PICC_IsNewCardPresent()) {
delay(50);
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
delay(50);
return;
}
// Show some details of the PICC (that is: the tag/card)
  Serial.print(F("Card UID:"));
  dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
  a = Serial.readString();
  Serial.println("kakak");
  Serial.println(a);

// Wait until the client sends some data
Serial.println("new client");
 while(!client.available()){
 delay(1);
 }

// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();

// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); //  do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");

client.print("Card UID:");
client.print(a);
client.println("</html>");
//delay(1);
//Serial.println("Client disonnected");
//Serial.println("");
}


texts: nodeMCU - 2 loops at a time - one continuously and second every 10 seconds

texts:
i have nodeMCU v3(esp8266) so i need to make 2 checks
1 check is the pin D1 which needs to be done continuously  and another check is web link check every 10 seconds,
problem is coz when i put delay then it stops the first check

void loop() {

 if (digitalRead(pinD1)==1){
       digitalWrite(pinD0, HIGH);
       delay(20000);
 }else{
       digitalWrite(pinD0, LOW);
 }

      loop2();

}

void loop2(){
   if (json1=="ON"){
    digitalWrite(pinD0, HIGH);
      delay(20000);
}else{
     digitalWrite(pinD0, LOW);
               delay(10000);

  }
}