texts: What phone carriers are available in the USA that are compatible with a sim900 breakout board

texts:
I was wondering what carriers are compatible with a sim900 breakout board. I know it needs a GSM network (AT&T,T-mobile,?) but what networks can I use?

It needs a 850/ 900/ 1800/ 1900 MHz frequency to work but who offers that frequency? I personally could not find what frequency cell phone companies offered. From how I understand it is that T-Mobile definitely will work.I have heard several different answers about companies like AT&T and I have seen discussion about sprint (which I don't understand because they are a CDMA carrier).

I have also heard that there are other carriers (Vondafone, nextel,Ting) that might be more cost effective for people like me who are only going to be using the text messaging.

Can someone please set me straight on who I can use.


texts:
What would be the (very) minimum schematic to make a ATtiny85 blink a led?

Restrictions are:

There must be a C program compiled and uploaded to it, just like an Arduino board would have. The code would use a simple "delay" to wait a little bit before changing the LED state.
The LED must be controlled by a "digital output port" just like an Arduino board would be.

This is the main question. Although I thought to ask a similar question with the restriction of "blinking exactly once per second", that would change completely the schema (not being a MINIMAL after all). So lets restrain to the main question. Maybe some day we can discuss the version 2.0!


texts:
When I learn the tutorial in

Analog Read Serial
Digital Read Serial

both of the code examples have a line of code of delay(1) and I cannot understand the comments clearly:

 delay(1);        // delay in between reads for stability

The stability for/of what?


texts: How can I read also the temperature with this GSR sensor?

texts:
Considering the GSR is the inverse of the Resistance, if I know the resistance and how much it increases for every celsius degree, the game would be done.
Here's how my code looks like at the moment:

const int GSR=A0;
int threshold=0;
int sensorValue;
const long interval = 1000;
unsigned long T = millis();

void setup(){
  long sum=0;
  Serial.begin(115200);
  delay(1000);

  for(int i=0;i<500;i++)
  {
  sensorValue=analogRead(GSR);
  sum += sensorValue;
  delay(5);
  }
  threshold = sum/500;
   Serial.print("threshold =");
   Serial.println(threshold);
  }

void loop(){

  if( millis() - T >= 250)  {
   int temp;
  sensorValue=analogRead(GSR);
  Serial.println(sensorValue);
  temp = threshold - sensorValue;
  T = millis();

  }
  }

The page of the sensor:
http://www.seeedstudio.com/wiki/Grove_-_GSR_Sensor


texts: Arduino Pico doesn't work with ST7735 screen

texts:
I am attempting to get the graphicstest example bundled with the Adafruit ST7735 library for the 0.96 inch LCD screen.
The example runs fine and serial communication is up and running. However, nothing outputs on the screen. I verified that the code works with other Arduino boards and that I have it properly wired -> SCK to SCL, MOSI to SDA, etc.
I'm not sure if I am doing something wrong, or if this is a limitation of the board.
Edit: I added the modified graphicstest code to the Internet, it can be found here: https://drive.google.com/file/d/1cFOgQXhhH1vou0KUrFzBDMp0iiIp1Yuy/view?usp=sharing
I also added a crude diagram of how the screen is wired up to the Pico. Note that the LCD is powered externally since the Pico cannot handle the current draw of powering the LCD.
https://drive.google.com/file/d/1RmZSHBcelwC9caLoQC9iE5Lb4eHG9S2O/view?usp=sharing


texts: How do I send HTTP request using ESP8266 to other port than 80?

texts:
I currently have a working connection to my ESP8266 module.

However, I can only connect to a server using the port 80, is it possible to choose a different port?

I can connect using AT+CIPSTART="TCP","192.168.122.46",80,
but I get an ERROR CLOSED when using AT+CIPSTART="TCP","192.168.122.46",8090 for example

Also, how do I send an HTTP request using the AT+CIPSENDcommand?

UPDATE: Stupid me, it was just Firewall blocking it...


texts: Is it possible to use SPI on Redbot Mainboard?

texts:
My students use the Sparkfun RedBot Inventor's Kit for their final design projects. The documentation about this board isn't great. There are connectors to SPI pins (they are not soldered to headers, but they exist, see diagram below); however the bumpers and wheel encoders use pins 10 and 11, which are pins used in SPI communication.

My question is: is it possible to solder headers into that SPI socket and use SPI communication without interfering with the bumpers and wheel encoders (for example if my students want to hook up a 7-segment display to show the RedBot's speed)?


texts: How Can I convert my arduino code to C/C++ embedded code

texts: For example I have an code for arduino but I want to change it to embedded C to create more professional project with different hardware. is there any tutorial? I know the logic and the most of the codes are the same. I just wanna know about libraries or pin definitions for LCD and buttons.


texts:
I'm using an ESP8266 (NodeMCU v3). I want to set a PIN high if a soft wdt reset occurs (not expecting one). Is there a way I can do that?

Can I attach something on TX pin of the board and watch for crash dump? Maybe another Arduino?


texts: I am trying to use an Uno to detect if an LED is on or not. Sounds simple, but I am tearing my hair out on this one, here is why.... This is a model railway application and I want to detect an LED being lit on the control panel showing how a route (points/turnouts) is set. The LED is lit by a point position indicator (www.blocksignalling.co.uk/index.php/points-position-indicator-ppi4-dc) which works perfectly but the LEDs are not permanently on when lit, even though they appear so, they are pulsed at around 8khz. I tried using opto isolators triggering an digital input on the Uno. They all happily detect 'no light' and the pin goes HIGH, but when the led is lit, the pin flucuates between 0 and 1 so not a true or stable LOW. I also made my own opto using a TCRT5000 with the leds pointing at eachother encased in shrinkwrap, using standard breadboard set-up which worked perfectly when powering the transmitter from the Uno, but same result when powered from the LED. Anyone out there got any ideas please?


texts:
I am wondering what the second line of code does:

int16_t GyX;
GyX=Wire.read()<<8|Wire.read();

Also, how can I write the GyX value to EEPROM?

From what I understand, int16_t is a two-bytes value. The Wire.read() returns a single byte. The <<8 shifts the bits by one byte to the left in order to read the higher order bits, and the last part writes the next wire read (lower order bits). Basically, reads wire twice and stores those values in the int. Is that correct?

For the writing, would

EEPROM.write(addr, GyX >> 8);
EEPROM.write(addr, GyX & 0xff);

do the trick? (First line records the higher order bits, while second records the lower order ones)


texts: Issue regarding executing sketch code when not connected to USB

texts:
`I have an Arduino Uno A000066 Board R3 that has an Arduino A000079 Motor Shield Rev3 attached to it. Also I have connected two DC Servo Motors to the Motor Shield and wrote the following sequence:

 void setup()
    {
      //Setup Channel A
      pinMode(12, OUTPUT);     //Initiates Motor Channel A pin
      pinMode(9, OUTPUT);      //Initiates Brake Channel A pin

      //Setup Channel B
      pinMode(13, OUTPUT);     //Initiates Motor Channel A pin
      pinMode(8, OUTPUT);      //Initiates Brake Channel A pin
    }

    void loop()
    {
      //Phase 1 - going to the wall
      //Motor A forward - Max Speed
      digitalWrite(12, LOW);   //Establishes forward direction of Channel A
      digitalWrite(9, LOW);    //Disengage the Brake for Channel A
      analogWrite(3, 255);     //Spins the motor on Channel A at max speed

      //Motor B forward - Max Speed
      digitalWrite(13, HIGH);  //Establishes forward direction of Channel B
      digitalWrite(8, LOW);    //Disengage the Brake for Channel B
      analogWrite(11, 255);    //Spins the motor on Channel B at max speed

      delay(4000); // Adjust to correspond the distance

  //Phase 2 - getting back to initial point
  //Motor A backward - max speed
  digitalWrite(12, HIGH);  //Establishes backward direction of Channel A
  digitalWrite(9, LOW);    //Disengage the Brake for Channel A
  analogWrite(3, 255);     //Spins the motor on Channel A at max speed

  //Motor B backward - max speed
  digitalWrite(13, LOW);   //Establishes backward direction of Channel B
  digitalWrite(8, LOW);    //Disengage the Brake for Channel B
  analogWrite(11, 255);    //Spins the motor on Channel B at max speed

  delay(4000);

  //Phase 3 Stop for 7.5 seconds
  // Motor A stop
  digitalWrite(9, HIGH);   //Engage the Brake for Channel A
    //Motor B stop
  digitalWrite(8, HIGH);   //Engage the Brake for Channel B
  delay(7500);

  //Phase 4 Go to second point
  //Motor A forward - max speed
  digitalWrite(12, LOW);  //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255);    //Spins the motor on Channel A at full speed

  //Motor B forward - max speed
  digitalWrite(13, HIGH);  //Establishes foward direction of Channel B
  digitalWrite(8, LOW);    //Disengage the Brake for Channel B
  analogWrite(11, 255);    //Spins the motor on Channel B at half speed

  delay(2000); // Adjust to correspond the distance

  //Phase 5 Final Stop
  //Motor A - stop
  digitalWrite(9, HIGH);   //Engage the brake for Channel A
  //Motor B - stop
  digitalWrite(8, HIGH);   //Engage the brake for Channel B

  delay(60000);        // 1 minute stop
}

While connected to USB, the device executes perfectly the sequence. As soon I run the sequence using the DC Source, the device does not respect any part of the coding. It started simply going forward while reversing the polarity randomly blocking the movement sometimes.

Looking forward to your suggestions.


texts: Can HC-05 Continuously Stream data and read data at the same time?

texts:
I am trying to have my Arduino Stream an Analog Signal using Bluetooth Module (HC-05) while being able to read commands from another Micro-controller using the same Bluetooth Module.

Currently, I am using Arduino Uno for this.


texts: Using 2 HC12’s to both send a receive data

texts:
I am new to using an Arduino, sorry if this is very basic. I have 2 Arduinos and I have hooked up 1 HC12 and a joystick to each. I wanted to know if it is possible to send the x and y inputs of the joystick of each arduino to the other simultaneously and storing them in a variable to be able to use them on the other arduino.
So arduino 1 would store x1 and y1 which are the joystick inputs of arduino 2. And arduino 2 will store x2 and y2 which are the joystick inputs of arduino 1.


texts:
I have attached photo of the clone Uno board recently acquired, and I am working on a Mac OS X 10.7.5

I have sourced the solution from
http://javacolors.blogspot.com/2014/08/dccduino-usb-drivers-ch340-ch341-chipset.html

Which suggests to install 340/341CH drivers and run a sudo code. When I plug in the Uno board, the Arduino IDE still does not show under port selection, the "dev.tty.usbserial"

and as such I cannot contact or upload any command to the Uno board. Been trying for a whole day.. please help if you know a possible solution

This is the board:

I bought the board from this site:

http://www.aliexpress.com/item/UNO-KIT-Upgraded-version-of-the-For-Starter-Kit-the-RFID-learn-Suite-Stepper-Motor-ULN2003/1207142899.html

screenshot from the IDE does now show any usbserial


texts:
Looking at this Time Arduino library because I would like to send time stamps with data across my HC05-PC channel.

https://playground.arduino.cc/Code/Time

I wrote this function to get the time at any point

String getTime() {
    String timeSecond = String(second());
    String timeMinute = String(minute());
    String timeHour = String(hour());
    String timeDay = String(day());
    String timeMonth = String(month());
    String timeYear = String(year());

    String now = timeHour + ":" + timeMinute + ":" + timeSecond + " " +
        timeMonth + "/" + timeDay + "/" + timeYear;

    return now;
}

It seems in the docs he provides info on how to set the default time on a Linux/Unix system so that this library will always be grabbing the correct time by editing some bash files.

When I run the function, having been compiled on Windows, it begins running on 1/1/1970 0:0:0.

He does not provide any documentation for setting the Windows time stamp. How would I go about doing that?


texts: How to simulate delay() to debounce mechanical button using millis()?

texts:
Im trying to use the millis() function as a replacement for the delay() function in order to debounce a mechanical button. This is for an electric drum kit I am building. Im using a teensy Arduino to send MIDI signals from the drum pads to an external music program. The mechanical button needs to be responsible for cycling through five different states which change the MIDI signal sent from each pad, thus changing the sound, as well as lighting up one of five LEDs on my drum pad so I know which state i'm in.  However I cant use delay() to debounce the button because that effects the efficiency of the drum pads, with some hits not being registered, latency etc.

Im trying to debug the code by just getting the LEDs to light up correctly when I press the button. This was the original code I wrote with the delay() function. This worked perfectly to debounce the button, but messed with my drum pads:

int but = 12;
int led0 = 7;
int led1 = 8;
int led2 = 9;
int led3 = 10;
int led4 = 11;

int ledCase = 0;
int butState = 0;
int oldButState = 0;

void setup()   {
pinMode(led0, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(but, INPUT_PULLUP);
}

void loop()    {

   oldButState = digitalRead(but);
   delay(10);
   butState = digitalRead(but);

   if (butState != oldButState && butState == LOW) {
     ledCase += 1;
     oldButState = butState;
   }

   if (ledCase > 4) {
    ledCase = 0;
   }

   Serial.println(ledCase);

switch (ledCase) {
case 0:
digitalWrite(led0, HIGH);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
break;
case 1:
digitalWrite(led0, LOW);
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
break;
case 2:
digitalWrite(led0, LOW);
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
break;
case 3:
digitalWrite(led0, LOW);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);
digitalWrite(led4, LOW);
break;
case 4:
digitalWrite(led0, LOW);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, HIGH);
break;
}
}

This is what I tried to use to replace the delay() function, but that hasn't worked. Note I added these lines in and removed the delay section:

unsigned long onTime;
unsigned long delayTime;

void setup() {
delayTime = millis() + 10;
}

void loop()    {
oldButState = digitalRead(but);
onTime = millis();
if (onTime >= delayTime) {
butState = digitalRead(but);
delayTime = millis() + 10;
}
}

Any pointers as to how I can make the millis() function work to debounce this would be would be very much appreciated, thank you :)


texts: Can I use GPS sensors in a country (India) that doesn't have its own GPS Sattelites?

texts: I am living in India. I want to work on Arduino Projects with GPS Modules. But only a few countries like US, Russia, China etc. have their own GPS satellites. India is working on it. So I am hesitating to buy GPS sensors. Can I work normally with GPS modules in my country as shown in Online projects in my country ?


texts:
I want to use a ATtiny85 to check the voltage of two 12 V batteries (later to control a relay). Therefore I'm using the analogRead() function. For programming I'm using an Arduino Mega 2560 board.

//                           +-\/-+
//  Ain0       (D  5)  PB5  1|    |8   VCC
//  Ain3       (D  3)  PB3  2|    |7   PB2  (D  2)  INT0  Ain1
//  Ain2       (D  4)  PB4  3|    |6   PB1  (D  1)        pwm1
//                     GND  4|    |5   PB0  (D  0)        pwm0
//                           +----+

For A1 this works perfectly fine. But for A2 or A3 I'm getting always a value of 15 V (thus the analog input gives 1023 respectively it thinks there is 5 V on the pin, which is not the case). I tried A0 as well, but it's the same.

For seeing the current value I put a serial - USB converter on RX, TX on PB3, PB4. So I guess they cannot work properly as analog inputs then. But still A0 does not work and without serial my LED is always on without having a voltage over 12 V.

At the moment I don't know what to do about it. No matter which of the analog pins I choose, I'm getting always a wrong value (except A1).

I'm not a hundred percent sure about A0. On some diagrams there is an A0 pin, on some not. But I tried to remove all the serial communication code and still having the LED 0 on high.

Thanks in advance!

void setup() {
  pinMode(0, OUTPUT);
  pinMode(1, OUTPUT);
  digitalWrite(0, LOW); // led for displaying the voltage
  digitalWrite(1, LOW); // blinking status led
  int sensorValue1 = 0;
  int sensorValue2 = 0;
  Serial.begin(9600);
}

void loop() {
  int sensorValue1 = analogRead(A1);
  int sensorValue2 = analogRead(A0);
  // <- the problem, A2, A3 do not work as well
  float voltage1 = sensorValue1 * (5 / 1023.00) * 3;
  float voltage2 = sensorValue2 * (5 / 1023.00) * 3;
  Serial.print(voltage1);
  Serial.print("--");
  Serial.print(voltage2);
  Serial.println();
  if ((voltage1 > 12) || (voltage2 > 12)) {
    digitalWrite(0, HIGH);
  } else {
    digitalWrite(0, LOW);
  }
  digitalWrite(1, HIGH);
  delay(1000);
  digitalWrite(1, LOW);
  delay(1000);
}

SOLUTION:
As suggested by Andrei Dragan the problem was the serial communication, which uses just the same pins as the analog inputs A2 and A3. When turned off, the problem disappeared.

As the serial communication is quite useful for me, right now I'm still using the serial communication but only with the pin for sending data. The pin for receiving data is turned off. It looks like this:

#include <SoftwareSerial.h>

#define RX    -1   // *** turned off
#define TX    4   // *** D4, Pin 3

SoftwareSerial Serial1  (RX, TX);

(I don't know if this is the best way, but it works for me.)

Once again, thanks for the help!


texts: CAN-Bus shield, SD-card module & LED_BUILTIN use D13; possible collision?

texts:
To my knowledge the SeeedStudio CAN-Bus shield utilizes D13, and so does the SD-card module I use. And also Arduino Uno's LED_BUILTIN is 13. Am I in danger of some sort of collision here?

I have read this question, but that one describes situation where both modules are on a single shield.

Why I am alerted: I can perform following sequence: turn the LED on, open file, write, close file, turn the LED off, no apparent problem here. But when I connect my CAN-Bus shield to merely read messages (i.e. no sending data to the shield, not on purpose) my car behaves funny as if I still somehow managed to send some rogue bytes to the shield. (Right side windows and mirror are dead, infotainment display shows dead splash screen, dashboard complains about "engine malfunction" and airbags...)

I wonder if by writing to the SD-card and possibly turning the LED on I didn't send some bytes to the shield. Do I need to somehow Select Slave?


texts: H Bridge for microcontroller power management?

texts:
Is it fine to use L298 N Dual H Bridge Stepper Motor Driver Module to control power of other ICs in a multiple microcontroller setup?

I intend to reduce power consumption in by powering communication ICs through the H bridge to allow switcching them off if not needed. Does a L298 based H bridge module like shown below supply clean stable DC current to someting like the ESP8266?

Module shown below contains condensators, i assume to reduce ripple effect created by L298.


texts:
So I have a program that works great on the Mega, it uses serial 3 to read and streams out to the USB (I posted a previous question which someone answered)  I tried to use Serial (D0) to read and then write to serial, which did not work.  So now I am looking in to Software Serials

Is there a difference between a real serial and software serial as it does not seem to be working, It all runs a bit slower

#include <SoftwareSerial.h>

const int DesiredRPM=300;  // Setting Desired RPM Here.
const int MotorPWMPin=4;
int inByte = 0;         // incoming serial byte
unsigned char Data_status=0;
unsigned char Data_4deg_index=0;
unsigned char Data_loop_index=0;
unsigned char SpeedRPHhighbyte=0; //
unsigned char SpeedRPHLowbyte=0;

int SpeedRPH=0;
const unsigned char PWM4dutyMax=255;
const unsigned char PWM4dutyMin=100;
unsigned char PWM4duty=PWM4dutyMin;  // have to set a default value make motor start spining

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
    pinMode(MotorPWMPin, OUTPUT);
    Serial.begin(115200);  // USB serial
    Serial3.begin(115200);  // XV-11 LDS data

    // prints title with ending line break
    Serial.println("Arduino Neato XV-11 Motor control board v0.1 by Cheng-Lung Lee");

    // Pick your magic number and drive your motor , 178 is 178/255*5V=3.49V
    analogWrite(MotorPWMPin, PWM4duty );

    mySerial.begin(115200);
}

void loop() {
    // if we get a valid byte from LDS, read it and send it to USB-serial
  if (Serial3.available() > 0) {
    // get incoming byte:
    inByte = Serial3.read();
    //Serial.print(inByte, BYTE);
    //Serial.write(inByte);
    Serial.print((char)inByte);
    decodeData(inByte);
  }

  if (mySerial.available() > 0) {
    // get incoming byte:
    inByte = mySerial.read();
    //Serial.print(inByte, BYTE);
    //Serial.write(inByte);
    Serial.print((char)inByte);
    decodeData(inByte);
  }

}

void decodeData(unsigned char inByte){
  switch (Data_status){
  case 0: // no header
  if (inByte==0xFA)
  {
    Data_status=1;
    Data_loop_index=1;
  }
    break;
  case 1: // Find 2nd FA
    if (Data_loop_index==22){
      if (inByte==0xFA)
      {
        Data_status=2;
        Data_loop_index=1;
      }
      else // if not FA search again
      Data_status=0;
    }
    else{
      Data_loop_index++;
    }
    break;
  case 2: // Read data out

     if (Data_loop_index==22){
      if (inByte==0xFA)
      {
        Data_loop_index=1;
      }
      else // if not FA search again
      Data_status=0;
    }
    else{
      readData(inByte);
      Data_loop_index++;
    }
    break;
  }

}
void readData(unsigned char inByte){
  switch (Data_loop_index){
    case 1: // 4 degree index
    Data_4deg_index=inByte-0xA0;
//      Serial.print(Data_4deg_index, HEX);
//      Serial.print(": ");
    break;
    case 2: // Speed in RPH low byte
    SpeedRPHLowbyte=inByte;
    break;
    case 3: // Speed in RPH high byte
    SpeedRPHhighbyte=inByte;
    SpeedRPH=(SpeedRPHhighbyte<<8)|SpeedRPHLowbyte;

    SpeedControl ( DesiredRPM ) ; //
//      Serial.print(SpeedRPHhighbyte, HEX);
//      Serial.println(SpeedRPHLowbyte, HEX);
    break;
    default: // others do checksum
        break;
  }
}

// Very simple speed control
void SpeedControl ( int RPMinput)
{
 if (Data_4deg_index%30==0) {  // I only do 3 updat I feel it is good enough for now
  if (SpeedRPH<RPMinput*60)
     if (PWM4duty<PWM4dutyMax) PWM4duty++; // limit the max PWM make sure it don't overflow and make LDS stop working
  if (SpeedRPH>RPMinput*60)
     if(PWM4duty>PWM4dutyMin) PWM4duty--;  //Have to limit the lowest pwm keep motor running
  }
  analogWrite(MotorPWMPin, PWM4duty ); // update value
}


texts: Why do some pins have a different PWM frequency?

texts:
According to the Arduino reference for analogWrite(), the PWM frequency on most pins is ~490 Hz. However, it's ~980 Hz for pins 5 and 6 on the Uno, and for pins 3 and 11 on the Leonardo.

Why are these different? Is it a deliberate design feature, or is it somehow dictated by the hardware?


texts: How do I join two RGB ledPanel 32x64 in order to get one 64x64?

texts:
I'm making a project to make a pixelArt of 64x64 using two 64x32 RGB ledMatrix and Arduino MEGA.
This is the RGB Panel I am using.
I use ADAFruit and RGBMatrixPanel libraries in my Arduino Code and if I connect the Arduino pins to the RGB panel it works, but the problem is when I try to connect the output of the first panel to the input of the second, I saw the "same image duplicated" but with different brightness, and if I change the length of the panel seems to print random LEDs.
I know that Adafruit is thought to get a screen with max of height of 32, but I don't care, because for my purpose you can assign each pixel programmatically in order to print the proper image.
I followed this guide in order to make the connection with a panel of 64x32.
I think that I have to change my code and also my physical connections, but I don't know how, can anyone help me?
Other option that I thought was create another matrix2 instance at the same code using different PINS, but this is very weird.
This is the current connections: (I have a power supply of 5v - 10A)

This is the result that I have: (duplicated in both screens with a brighness/weird shadow in the second)

And this is the final result that I'm looking for: (this is made with two Arduino Megas)

Thanks in advance!


texts: Is there a way to get my MacBook's date and time into Arduino IDE?

texts:
I am using a DS3231 RTC module. It requires to set the time every time it is reset. I was wondering if I could read my MacBook's time and date and feed into the module at the setup stage. Is this possible?

P.S. I do not have to use a battery.


texts: WebSocket client for ArduinoHttpClient conditional if with readString() incoming data buffer

texts:
I'm having issues implementing a web socket on the Arduino/Genuino to procress a string received and do something respectively.

I'm using SimpleWebSocket example, edited for my purpose, from the ArduinoHttpClient...

don't seam to get the hangs of it. don't know what i'm doing wrong, cannot store the received string object on a string variable or use the readString() method on and if statement to compare with a string to decide what flow path to get in to

This is the code im trying:

/*
  Simple WebSocket client for ArduinoHttpClient library
  Connects to the WebSocket server, and sends a hello
  message every 5 seconds

  note: WiFi SSID and password are stored in config.h file.
  If it is not present, add a new tab, call it "config.h"
  and add the following variables:
  char ssid[] = "ssid";     //  your network SSID (name)
  char pass[] = "password"; // your network password

  created 28 Jun 2016
  by Sandeep Mistry

  this example is in the public domain
*/
#include <ArduinoHttpClient.h>
#include <WiFi101.h>
#include "config.h"

char serverAddress[] = "192.168.1.140";  // server address
int port = 8000;

WiFiClient wifi;
WebSocketClient client = WebSocketClient(wifi, serverAddress, port);
int status = WL_IDLE_STATUS;
int count = 0;

void setup() {
  pinMode(6, OUTPUT);

  Serial.begin(9600);
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);                   // print the network name (SSID);

    // Connect to WPA/WPA2 network:
    status = WiFi.begin(ssid, pass);
  }

  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
}

void loop() {
  Serial.println("starting WebSocket client");
  client.begin();

  while (client.connected()) {
    int messageSize = client.parseMessage();

    if (messageSize > 0) {
      String test = client.readString();
      Serial.println(client.readString());
      Serial.println(test);
      if (client.readString() == "off") {
        Serial.println("low");
        digitalWrite(6, LOW);
      }
      else {
        Serial.println("high");
        digitalWrite(6, HIGH);
      }
    }
  }

  Serial.println("disconnected");
}

On the example above, you can see in the void loop, after I check there's incoming data with messsageSize I store the incoming data using readString on a variable test, which I then println, this shows and empty line, although when I directly via println readString it shows some data, so the data is coming in... subsequently when I try to use the data from the incoming buffer on and if statement to compare with a string is wont work.

I've tried everything I can think off, puting the string to compare in to a variable and compare them, using Compare method from the object and I cannot even remember what else.

does anyone have any advice on how to do this, maybe the library is buggie, maybe I'm doing it wrong, any other libraries that anyone can recommend, I've looked around and this is the only one that looked simple enough to get started with and had the most examples.


texts: fast memory buffer and setting output state

texts:
I'm intending to set up a digital delay using a circular buffer (in SRAM) with an Arduino Due (@84MHz). The lenth of the buffer determines the delay. I need about 1us resolution and the delay needs to be dynamically settable between 0 - 500us. I'll probably use most of the memory just for the buffer.

I've got a very basic setup going (with a fixed delay, no buffer), that just updates a temporary variable with the current state of the input signal and then writes the whole word to another port in order to set the state.

Next up is designing the buffer so I can add some delay to the output of the signal.

Filling the buffer using interrupts watching signals on the same port shouldn't be too difficult but I am wondering:

a) taking speed in consideration, which buffer method will have the least processing overhead? Memory stack or an array[], or someting else?

b) is there a way to read a port and set an output port in one clock cycle? I am now using REG_PIOD_ODSR=outbyte; but ideally it needs to point to a memory address directly.


texts: SPI communications with an Yost Labs IMU

texts:
I am pairing an Arduino UNO with a Yost Labs 3-Space Sensor Nano, the user manual for said sensor can be found here and the user manual for the sensor family here (kinda confusing, Yost Lab's documentation contradicts itself IMO)
This is my code, pretty straight forward (although this is my first time working with SPI). I am 100% sure the wiring is correct, and I have attached a diagram of my wiring here. The logic voltage converter I am using is this
I believe that as per the user manual, this should successfully return 3 floats in 4 bytes each, corresponding to the filtered euler angles of pitch, yaw, and roll. However, all I am reading is bytes full of 0xFF (or 11111111 in binary) which I believe corresponds to null / no command.
Are there any visible errors in my code?
#include <SPI.h>

SPISettings settings(6000000, MSBFIRST, SPI_MODE0 ); //variable to hold SPI settings
//Set Slave Select, MOSI, MISO, CLK
const int CSN = 10;
const int SI = 11;
const int SO = 12;
const int CLK = 13;

// Needed to convert the bytes from SPI to float
union u_types {
   byte b[4];
   float fval;
} data[3];  // Create 3 unions, one for each euler angle

void setup() {
 //Set Pin Modes
 pinMode(CSN, OUTPUT);
 pinMode(SI, OUTPUT);
 pinMode(SO, INPUT);
 pinMode(CLK, OUTPUT);
 //Set Slave Select High to Start i.e disable chip
 digitalWrite(CSN, HIGH);
 //Initialize SPI
 SPI.begin();
 //pour a bowl of serial
 Serial.begin(9600);
}

//function to transfer commands through SPI
byte transferByte(byte byteToWrite) {

 byte Result = 0x00;
 digitalWrite(CSN,LOW);
 delay(1);
 Result = SPI.transfer(byteToWrite);
 delay(1);
 digitalWrite(CSN,HIGH);
 return Result;
}

//function to swap endian
void endianSwap(byte temp[4]) {
 byte myTemp = temp[0];
 temp[0] = temp[3];
 temp[3] = myTemp;
 myTemp = temp[1];
 temp[1] = temp[2];
 temp[2] = myTemp;
}

void loop() {
 SPI.beginTransaction(settings);

 // Clear the internal data buffer on the IMU
 byte result = transferByte(0x01);
     Serial.print("Cleared internal buffer. Result: "),Serial.println(result);

 // Send start of packet:
 result = transferByte(0xF6);
      Serial.print("Send start of packet. Result: "),Serial.println(result);

 // Send command (tared euler angles)
 result = transferByte(0x01);
      Serial.print("Send commmand 0x01. Result: "),Serial.println(result);

 // Get status of device:
 result = transferByte(0xFF);
      Serial.print("Status of device. Result: "),Serial.println(result);

 while (result != 0x01) {  // Repeat until device is Ready
   delay(1);
   result = transferByte(0xFF);
   Serial.print("Status of device. Result: "),Serial.println(result);
 }

 // Get the 12 bytes of return data from the device:
 for (int ii=0; ii<3; ii++) {
   for (int jj=0; jj<4; jj++) {
     data[ii].b[jj] =  transferByte(0xFF);
     delay(1);
   }
 }

 SPI.endTransaction();

 for( int mm=0; mm<3; mm++) {
   endianSwap(data[mm].b);
 }

 Serial.print("fval 1:"), Serial.println(data[0].fval);
 Serial.print("fval 2:"), Serial.println(data[1].fval);
 Serial.print("fval 3:"), Serial.println(data[2].fval);

 delay(3000);
}


texts: 65 hall effect sensors as switches to be used as a keyboard with a teensy

texts:
I'm trying to wire up a silly little keyboard using hall effect sensors and magnets in a glove. The idea being only I can use the keyboard since I'll have the glove.

The sensors are 3 pin, (vcc, gnd, and an output that sends 5v out when a magnetic field is present. I don't have anywhere near enough pins on the teensy for all the sensors. Could I just use several port expanders? Are there issues with using 4 or 5 at once? How many keys could be pressed at a time?

Is there a better option than all those expanders?

Also I know that this keyboard will be ugly and completely impractible to use regularly, but I thought it would fun to show off.


texts: How to measure ultrasonic sensor without pulsein method?

texts:
I am a front-end developer so I don't really know Arduino. Anyway, my teacher gave me a project.

In short, I have to measure distance with HC-SR04. But the problem is that the teacher wants me to use a timer. But I can't understand how can I do that.

Thank you for helping.


texts:
The below code starts off with lots of data in the beginning, distracting the reader from the actual code.  What is the best practice to clean this up:

#include <Wire.h>
// For LED Backpack
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
// For LCD Shield
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

// For pixel Units, such as hero
#include <Unit.h>

Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

Unit *hero;
boolean doesNeedRedraw = true;
boolean textNeedsRedraw = true;
int8_t lastButtonPress = 0;
int8_t frame = 0;

void setup() {
  /* Important Setup Routine */
}

static const uint8_t PROGMEM
  smile_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10100101,
    B10011001,
    B01000010,
    B00111100 },
  neutral_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10111101,
    B10000001,
    B01000010,
    B00111100 },
  frown_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10011001,
    B10100101,
    B01000010,
    B00111100 },
  walls_bmp[] =
  { B10100000,
    B10110000,
    B10010000,
    B11011100,
    B01000100,
    B01110100,
    B00010100,
    B00011100 };

void loop() {
  /* Important Main Loop Routine */
}


texts:
I've often seen cli() and sbi() in Arduino code. I usually don't mind them as I know what they do (clear or set the bit given as second argument in the register of the microcontroller given as first). I've always thought that those functions where only a clear way to perform simple bit manipulation, which can be quite error-prone. Something like that:
#define cli(reg,bit) (*reg &= ~(1 << bit) and #define sbi(reg,bit) (*reg |= (1 << bit)).

Then I found out that the actual implementation is as follows:

#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

It's quite like I used to think... but with two extra macros.
I looked for them in the Arduino libraries:

#define _BV(bit) (1 << (bit))

and

#define _SFR_BYTE(sfr) _MMIO_BYTE(_SFR_ADDR(sfr))

which contains

#define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))

and

#if _SFR_ASM_COMPAT
#if (__SFR_OFFSET == 0x20)
#define _SFR_ADDR(sfr) _SFR_MEM_ADDR(sfr)
#elif !defined(__ASSEMBLER__)
#define _SFR_ADDR(sfr) (_SFR_IO_REG_P(sfr) ? (_SFR_IO_ADDR(sfr) + 0x20) : _SFR_MEM_ADDR(sfr))
#endif
#else  /* !_SFR_ASM_COMPAT */
#define _SFR_ADDR(sfr) _SFR_MEM_ADDR(sfr)

Further research took me to definitions I couldn't understand (for example because they are explained in comments using a lot of acronyms I don't know).
So I have the following questions:

Why is sfr casted to *(volatile uint8_t *)?
What do the acronyms used in that code mean? (ASM, SFR, MMIO)
Under what circumstances is __ASSEMBLER__ defined, and where (in which file)?
Why can't we simply write #define cli(reg,bit) (*reg &= ~(1 << bit) and #define sbi(reg,bit) (*reg |= (1 << bit))?


texts: What will happen if I set ARef to 3.3V and try to use adc connected to 5V

texts:
What will happen, if I try to measure voltage higher than ARef?
For example, my ref is 3.3V, and I try to measure 4.5V. Will it damage adc?


texts: Adafruit esp32 Feather Failing to compile

texts:
So yesterday, I was able to upload/compile given example code to the Esp32 Huzzah board. Today I couldn't even compile. Even carefully using the tutorial adafruit provides.

I was getting errors as given below. How do I fix this?

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1/tools/sdk/lib\libesp32.a(cpu_start.o):(.literal.main_task+0x14): undefined reference to `app_main'

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1/tools/sdk/lib\libesp32.a(cpu_start.o): In function `main_task':

/Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/cpu_start.c:503: undefined reference to `app_main'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial9availableEv+0x0): undefined reference to `uartAvailable'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial4peekEv+0x0): undefined reference to `uartPeek'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial4readEv+0x0): undefined reference to `uartRead'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial5flushEv+0x0): undefined reference to `uartFlush'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial5writeEh+0x0): undefined reference to `uartWrite'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial5writeEPKhj+0x0): undefined reference to `uartWriteBuf'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::available()':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartAvailable'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::peek()':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartPeek'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::read()':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartRead'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::flush()':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartFlush'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::write(unsigned char)':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartWrite'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::write(unsigned char const*, unsigned int)':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartWriteBuf'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Adafruit ESP32 Feather.


texts:
I am trying to interface sele EM2M, I am using Arduino Mega with RS 485 module. I want to read the internal registers I am using ModbusMaster library. The data which I want to receive is in the internal registers but I am not getting how can I read Internal registers. When I use other software to read data I am getting the out
I also wanted to know the difference between Internal Registers and Holding Registers
Another questions how are the frames formed for communication in rs485 from the above image I can understand 01 04 but from where do they get 00 1A please explain the same.


texts: How to send commands from ESP8266 to Arduino

texts:
I am fairly new to the Arduino ecosystem in general but I will try to explain what I am trying to achieve in the best way possible. I am still not sure what technically I want to do so hopefully someone can guide me in the right direction here.
I have both an Arduino UNO and a ESP8266 and my current goal is to be able to control my Arduino UNO while using my ESP8266 as a "bridge".
I am using johnny-five which enables me to send commands to my Arduino via a NodeJS application that I have. I was able to setup both sending commands to my Arduino from johnny-five over a usb port and I was also able to send commands to my ESP8266 from johnny-five over wifi, both times I loaded some Firmata on my chips.
What I want to do now is to be able to from my johnny-five application connect to my ESP8266 over wifi and not control my ESP8266 but control my Arduino instead. I know that what I am trying to do probably has a technical name for it but I don't know what it is so it's proving hard to google a way to do it. I tried having a Firmata on both my chips and have a TX<->RX connection between them, it seems like this is what you should to do send commands between them, but every command that I send is being processed by my ESP8266 instead.
I am assuming that this is both because I am not using the correct Firmata on my ESP8266 and maybe I am not initializing my board correct on johnny-five.
I understand that johnny-five is its own thing and a question for that should not be posted here. So if someone could only point me what should I research to make my ESP8266 act as this "bridge" I think I should be good to figure the rest.
My final goal here is to be able to control my Arduino from my NodeJS application (which is covered by johnny-five + firmata) over wifi. So maybe if what I am trying to do here is not the best way to achieve that (that does not including buying an arduino with wifi) I ask you to please point me in the right direction.
Thanks!


texts:
first of all, Im from Cuba, that means I may have some problems to find parts...

I have a little system to measure the water level in my house water tank. The system is pretty rough: a proximity sensor HC-SR04 well fixed in the top of the tank, some long wires to an ArduinoNano, and a LCD screen where I display information as: water level in liters and in %.

The problem is the proximity sensor HC-SR04 seems to be broken now, not work at all and I was thinking in replace it by raw cables

Something like in the image below, but maybe with more steps:

So... My questions are:

-Is this posible? I just test it with a glass of water and two short wires and it work, but sometimes it throw me some falses-positives... It may be my code: just light on a led if digitalpin X is high when I put two wires in the water (1 wire to arduino 5V pin and the other to the digitalpin I wanna check if is high), and it do it, but when I pull out the wires the led stay on for more than a few seconds.

-If it is posible, how long can be the wire? Is 10m ok?

Thanks


texts: New to Arduino: Should I learn C, C++ or both (C & C++)?

texts:
From what i've researched here is my thoughts on both

C++
I heard that you can create libraries using C++ in arduino. And you can use the Arduino IDE to do that stuff.  Here is the proof

http://arduino.cc/en/Hacking/LibraryTutorial

Notice that it uses the C++ syntax.

I also see arduino projects on github written on C++
https://github.com/search?l=C%2B%2B&q=Arduino&type=Repositories&utf8=%E2%9C%93

C

I heard that you can use AVR GCC and code it without the arduino ide. And I heard it's much faster than the arduino language because it's more closer to the metal. But I think it's harder to set up because you need a programmer into the Atmel chip, which is much more costlier compared to directly plugging in the arduino using the USB to printer cable. And you also need to download a bunch of stuff to get coding in pure avr gcc (win-Avr GCC, atmel studio etc.).

Which one should i learn C or C++? I prefer the easy to debug route. Or is it beneficial if i learn both?


texts:
I'd like to alter the "LED_T_ON" values using an I2C enabled device (i.e. RPi)

Code for Arduino Mega slave:

//slave

#include <Wire.h>

#define SLAVE_ADDRESS 0x08

const int PWR_LED = 43;
int LED_TinH_ON = 18;
int LED_T_ON = 5000;
int LED_T_OFF = 5000;

String inString = "";    // string to hold input
byte LastMasterCommand = 0;
int Mval;

char user_input;

class Relay {
  int relayPin;
  long OnTime;     // milliseconds of on-time
  long OffTime;    // milliseconds of off-time

  // These maintain the current state
  int relayState;                 // pumpState used to set the PUMP
  unsigned long previousMillis;   // will store last time PUMP was updated

  // Constructor - creates a Timer and initializes the member variables and state
  public:
  Relay(int pin, long on, long off)
  {
    relayPin = pin;
    pinMode(relayPin, OUTPUT);

    OnTime = on;
    OffTime = off;

    relayState = LOW;
    previousMillis = 0;  //ORIGINALLY 0
  }

  void Update()
  {
    // check to see if it's time to change the state of the TIMER
    unsigned long currentMillis = millis();

    if((relayState == HIGH) && (currentMillis - previousMillis >= OnTime))
    {
      relayState = LOW;  // Turn it off
      previousMillis = currentMillis;  // Remember the time
      digitalWrite(relayPin, relayState);  // Update the actual LED
    }
    else if ((relayState == LOW) && (currentMillis - previousMillis >= OffTime))
    {
      relayState = HIGH;  // turn it on
      previousMillis = currentMillis;   // Remember the time
      digitalWrite(relayPin, relayState);   // Update the actual RELAY
    }
  }
};

Relay relay3(PWR_LED, LED_T_OFF, LED_T_ON);

void setup() {
 // initialize serial communication with computer:
  Serial.begin(9600);

  Wire.begin(SLAVE_ADDRESS);

  Wire.onReceive(receiveData);
  Wire.onRequest(slavesRespond);

  pinMode(PWR_LED, OUTPUT);
}

void loop() {
  delay(1000);

  Serial.print("LED_T_ON=");
  Serial.println(LED_T_ON);
  Serial.print("LED_T_OFF=");
  Serial.println(LED_T_OFF);
  Serial.println();

  relay3.Update();

  switch (Mval) {
    case 1 ... 25:
      LED_TinH_ON = Mval;
      Serial.print("LED time on: ");
      Serial.print(LED_TinH_ON);
      Serial.println("h");
      LED_T_ON = LED_TinH_ON*1000;//*60*60;
      LED_T_OFF = (24-LED_TinH_ON)*1000;//*60*60;
    break;
  }
}

void receiveData(int byteCount) {
  LastMasterCommand = Wire.read();
  while (Wire.available()) {
    int msg = Wire.read();

    if (isDigit(msg)) {
      inString += (char)msg;
    }
  }
  Mval = inString.toInt();
  //Serial.println(LastMasterCommand);
  inString = "";
  //Serial.println(Mval);
}

void slavesRespond() {
}

When I change the value on the RPi the Arduino receives and displays the correct value but the timed relays don't actually use the updated values.

Am I missing something?


texts: What is an easy way to power a 3.3v BMP-180 barometer board from a 5v Arduino Nano?

texts:
Scenario:

I have a functioning weather station (temp/humid, MQ-2 smoke sensor, anemometer), and want to add a barometer.  The weather station is outside, linked to my inside display and RTC by the I2c&Power modules and ethernet cable.  The cable supplies 12v and I use a small converter to provide the 5v to run the I2c&Power board and the rest.

So I have 12v and 5v available out at the weather box.

Inside along with the RTC and LCD display I have a 2-port I2C&Power which will be used in the future (with the new pgpio library) to feed the info to an Rpi3 to create a web page to show changes over time.

The barometer module I bought is the BMP-180.  It is nice and tiny and looks perfect for the job, but the instructions all over the web tell me that it will burn up if powered by 5V.  The Arduino Nano does not have a 3.3v output pin like the Uno does.

Q:  What is the easiest way to accomplish adding this 3.3v board to the weather station?


texts:
I recently purchased a pcDuino 3B and I am very pleased with the Board so far. I can use the preinstalled arduino IDE to program the board from the board and run programs.

However, when I came to use I2C, it generated a load of errors with the built-in libraries when I tried to compile. I don't know why it did this, it does it when trying to compile any program using I2C. Here is the error list (Yes, I am using an Adafruit display library that works fine with exactly the same sketch on my laptop):

In file included from /usr/share/arduino/hardware/arduino/pcduino/cores/arduino/Stream.h:26:0,
                 from /usr/share/arduino/hardware/arduino/pcduino/libraries/Wire/Wire.h:9,
                 from Stopwatch_new.ino:1:
/usr/share/arduino/hardware/arduino/pcduino/cores/arduino/Print.h:47:23: error: ‘byte’ has not been declared
In file included from Stopwatch_new.ino:1:0:
/usr/share/arduino/hardware/arduino/pcduino/libraries/Wire/Wire.h:41:23: error: ‘byte’ has not been declared
Stopwatch_new.ino:5:51: error: cannot allocate an object of abstract type ‘Adafruit_RGBLCDShield’
/home/ubuntu/Arduino/libraries/AdafruitLCD/Adafruit_RGBLCDShield.h:68:7: note:   because the following virtual functions are pure within ‘Adafruit_RGBLCDShield’:
/usr/share/arduino/hardware/arduino/pcduino/cores/arduino/Print.h:47:17: note:  virtual int Print::write(int)
Stopwatch_new.ino:5:23: error: cannot declare variable ‘lcd’ to be of abstract type ‘Adafruit_RGBLCDShield’
/home/ubuntu/Arduino/libraries/AdafruitLCD/Adafruit_RGBLCDShield.h:68:7: note:   since type ‘Adafruit_RGBLCDShield’ has pure virtual functions
Stopwatch_new.ino: In function ‘void updateScreen()’:
Stopwatch_new.ino:125:27: error: call of overloaded ‘String(float&, int)’ is ambiguous
Stopwatch_new.ino:125:27: note: candidates are:
/usr/share/arduino/hardware/arduino/pcduino/cores/arduino/WString.h:44:14: note: String::String(unsigned int, unsigned char)
/usr/share/arduino/hardware/arduino/pcduino/cores/arduino/WString.h:43:14: note: String::String(int, unsigned char)
/usr/share/arduino/hardware/arduino/pcduino/cores/arduino/WString.h:42:14: note: String::String(unsigned char, unsigned char)

It seems that no one else is having this issue.

Just to clarify, the issue is not with my code or the library, it compiles fine on my other computer running WINDOWS but same Arduino version (1.5.3), same sketch code and same library code.

Help much appreciated, thanks!


texts: MQTT subscribe callback fails to be called in ESP8266 deepsleep mode

texts:
Refer to

ESP8266 deep sleep and MQTT

I executed the code in the given link. However i am not able to receive the subscribe message that are send from MQTT test broker(MQTT Lens) on the serial console.

Please help.
I am receiving successful call to both publish methods

#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char* ssid = "honored";
const char* ss_pswd = "12345678";
const char* mqtt_server = "iot.eclipse.org";

void callback(char* topic, byte* payload, unsigned int length);
WiFiClient EspClient;

PubSubClient client(EspClient);

void wifi_setup() {
  Serial.print("Connecting to: ");
  Serial.println(ssid);
  WiFi.begin(ssid, ss_pswd);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}
void reconnect() {
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    String ClientId = "ESP8266";
    ClientId += String(random(0xffff), HEX);
    if (client.connect(ClientId.c_str())) {
      Serial.println("connected");
      client.publish("outtopic", "hello world, finally");
      client.subscribe("/room/test");
    } else {
      Serial.print("failed, rc=");
      Serial.println(client.state());
      Serial.println("Try again...");
      delay(5000);
    }
  }
}
void sendMQTTMessage() {
  Serial.println("sending your message");
  if (!client.connected()) {
    reconnect();
  }
  client.publish("/sensor/pir", "on");
}
void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived: ");
  Serial.println(topic);
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
}

void setup() {
  Serial.begin(115200);
  wifi_setup();
  client.setServer(mqtt_server, 1883);
  sendMQTTMessage();
  client.setCallback(callback);
  delay(2000);
  Serial.println("going into deep sleep");
  ESP.deepSleep(10 * 1000000);
}

void loop() {

}


texts: Pass custom element of an array from an inherited class to main sketch

texts:
I'm building a base class that creates color patterns using FastLed's CRGB structure. I use the base class as inheritance for another more specific class that modifies a vector of colors (Pixels[]) and at some point I want to pass the color of a specific element from my class to the main sketch. But i'm having some issues with it, since the content of Pixels[] doesn't seem to match what I actually write in there.

Pattern.h:

class Pattern
{
    public:
    CRGB PixelAt(int idx);
    CRGB Pixels[6];
}

Pattern.cpp:

CRGB Pattern::PixelAt(int idx)
{
  // safety check
  if (idx >= 0 && idx < NumLeds)
  {
    return Pixels[idx];
  }
  else
  {
    Serial.print("Index out of bounds: "); Serial.println(idx);
    return CRGB::Black;
  }
}

TestPattern.h:

class TestPattern : public Pattern {
    void Tick(unsigned long millis);
}

TestPattern.cpp:

void TestPattern::Tick(unsigned long millis)
{
    for (int p = 0 ; p < NumLeds ; p++)
    {
      Pixels[p]=CRGB::Blue;
    }
}

Main Sketch:

for (int p = 0; p < NUM_PATTERNS; p++)
{
  // update pattern
  ledPatterns[p].Tick(millis());

  if (ledPatterns[p].Status == Enabled)
  {
    // sum the values of the pixels
    for (int l = 0; l < NUM_LEDS; l++) {
      leds[l] += ledPatterns[p].PixelAt(l);
    }
  }
}

I'm skipping parts of the code to make it easier to read, but I think with this much you should be able to help me make it work. I'm still getting acquainted with C and pointers, which is where I think the problem lies.

So how should I declare and use Pixels[] so that the Main Sketch, the base class and the inherited class all have consistent information?


texts: Why Commenting Serial.print() gives me a different value?

texts:
I am working on with Cypress and Arduino.I am trying to transfer the data from cypress and printing it to the Serial Monitor or Arduino. but the thing is when I am using Serial.print(j) it is showing the right value of i (See in the code about what is i and j), but when I comment or remove Serial.print(j) it is showing the wrong value of i
For example, suppose cypress is sending data 00001934a
and then I am reading this value using

int j = mySerial.read()-'0';
// -'0' is for chaging ascii data to normal integer
//for example ascii value of `0` is 48
//so mySerial will read 48
// and exprerssion value will become `48-48 = 0`

My code

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
Serial.begin(57600);
 while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

mySerial.begin(4800);
}

int  i = 0;
int j = 0;
void loop() {
if (mySerial.available()) {

        while(j!=49){
        i = i*10 + j;
        j = mySerial.read()-'0';
         //49 is the ascii value of a, I am using this for acting like
         //a flag, so that i can see the break in data

        Serial.println(j);//commeting this line is causing the problem
      }
   Serial.print(i);
   }
}

when the line is not commented the output was

0
0
0
0
1
9
3
4
49
193 //this is the value of i which is correct one

but when I comment the line Serial.println(j) the output was

   14569 // I don't know what the hack is this.

Hopefully the problem is understandable, but still, you can comment for more detail.
BTW I am using SoftwareSerial.


texts: Sim800L Uploading issues, HTTPACTION returns 0, 302, 701

texts:
I'm using the Sim800L module and the NEO6M GPS Module in combination with an Arduino nano to create a simple tracking device. I get the data from the GPS and try to upload it to my site with some simple PHP scripts. I'm using this code down here:

//the function - which is responsible for sending data to the web server
void sendLocation(String lat, String lon){
 Sim800l.listen();
 //The line below sets the URL we want to connect to
 Sim800l.println("AT+HTTPPARA=\"URL\", \"http://" + ipAddress +  "/log_info.php?dev_id=13&lat=" + lat + "&lon=" + lon + "\"");
 waitUntilResponse("OK");
 //GO
 Sim800l.println("AT+HTTPACTION=0");
 waitUntilResponse("200");
 Serial.println("Location sent");
 gpsPort.listen();
}

Unfortunately, when I try to use this code, in my serial monitor I get this message:

AT+HTTPACTION=0
OK
+HTTPACTION: 0,302,171
error

I Looked it up in the datasheet for the Sim800L, and the number 302 means "Found". I'm expecting the number 200 for "OK". I have no idea what I did wrong, the data is not being send to the web server for some reason. I hope you can help.
Thanks in advance!

EDIT:
The datasheet with all the errors for the Sim800L
https://www.elecrow.com/wiki/images/2/20/SIM800_Series_AT_Command_Manual_V1.09.pdf


texts: Connecting Arduino Yun to wifi with 802.1X authentication

texts:
Is it possible to connect the Yun to wifi using 802.1X authentication?  802.1X is WPA2-Enterprise that uses a username and password (per user) instead of one password (for every user).  I don't see a way to do it from the Yun web interface, but is there a way to do it from the linino terminal?

As far as I know, the Atheros AR9331 chip should be capable of this, but I don't see a way to do it with the software included on linino, there must be a way to install something for this?


texts: Uploading a sketch causing an error message in Arduino Uno

texts:
avrdude:

  no programmer has been specified on the command line or the config
  file
           Specify a programmer using the -c option and try again


texts: How is a 41KB char array filling up 256KB of program memory?

texts:
I have an array of 41,400 elements of type char, which I am trying to put in program memory on a Mega2560. It should have 256KB of flash memory, but when I try to compile my sketch, it says the size of the array is too large. Each char is one byte, so this array should be 41,400 bytes. I'm at a loss as to how this can be too big.

I have also tried using an array of byte variables (should be the same thing) with no success. This is the only variable going into program memory.

Here is the relevant line:

const char Array[] PROGMEM = {0,19,21,25,27,27,27,29,24, ... };

I have included avr/pgmspace.h

Thanks in advance for any help.


texts: How do I redefine the overlfow of compare interrupts in Arduino programming?

texts:
If I'm programming a pin change interrupt I can call attachInterrupt at various points in my code and change what function is called when the interrupt occurs.

The overflow and compareA/B interrupt calls are defined by the ISR macro which is evaluated at compile time, which therefore can't be changed at run time. One solution would be to make that function consist of a single line, which invokes a function pointer. If I'm reading the code correctly, this is how attachInterrupt is implemented. Short of mucking with the interrupt vector table (which seems like a bad idea, or at least very hard to debug if you screw it up), is there another way to redefine the overflow or compare interrupt functions?


texts: Difference in increment & decrement loop execution speed

texts:
I was experimenting with for loops when I noticed that a simple increment loop executes faster than a decrement loop. I can't think of any reason why it should be like that. Is there something in my code that is causing the different in execution speed?

The code is as follows:

// Global Variables
const int spk = 7;
const int led = 6;
int j = 0; // counter variable

void setup() {

  pinMode(spk, OUTPUT);
  pinMode(led, OUTPUT);
  Serial.begin(9600);
} // end of setup

void loop() {

  tone(spk, 300, 500); // first note with duration

  // increment loop
  for (j=0; j <= 500; j = j + 1) {
    digitalWrite(led, HIGH);
    Serial.println(j);
  } // end 1st note loop

  tone(spk, 100, 500); // second note with duration

  // decrement loop

  for (j = 500; j >= 0; j=j-1) {
    digitalWrite(led, LOW);
    Serial.print("the value is=");
    Serial.print("\t");
    Serial.println(j);
  } // end 2nd Note loop

} // end setup


texts: Missing character when introducing delay in the code

texts:
I am using the following code for reading any incoming message, and doing something after decoding the incoming string. There is a delay of 10sec in the code. When this delay is not introduced in the code, it is working nice. In this case, the output is like below.

+CIEV: "MESSAGE",1

+CMT: "+919080404532",,"2018/02/09,19:30:51+06"
This is an incoming test message

When the delay is introduced, I am unable to see the message on the serial monitor, and subsequent action is not taken by the code. The output is like below.

+CIEV: "MESSAGE",1
+CMT: "+919080404532",,"2018/02/09,1

It is clear that, I am missing some character in serial monitor. If delay is reduced to 400 ms, the output is like below.

+CMT: "+919080404532",,"2018/02/09,19:30:51+06"
This is an incoI am working other job

I checked the following, but did not get any improvement.

Serial.flush and mySerial.flush
Increased both hardware, and software aerial buffer size
used if (!mySerial.available() before delay
Changed baud rate for both
Instead of of Serial.readString(), I used Serial.read() character by    character inside function loop

Without use of the delay, it is working nice. I Think you guys are experienced, and can sort out the problem easily.

//while Introducing any delay in function loop, incoming message cant be read
//working with power failure but with serial monitor
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);  // TX-Pin11, RX-Pin10
String str="";
void updateSerial()
{
  delay(2000);
  while (Serial.available()) {
    mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while(mySerial.available()) {
    Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
  }

}

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

void loop()
{
 Serial.println("I am working other job");
 //delay(10000);            //If you give this delay, then incoming message cant be read
 smstask();
}

void smstask()
{
if(mySerial.available())
{
str=mySerial.readString();
Serial.println(str);
int bra = str.indexOf('@');
int ket = str.indexOf('#');
String str1=str.substring(bra+1,ket);

if(str1=="server")
{
Serial.println(str);
int i=random(1,500);
String str2=(String)i;
String str3="@deviceA#"+str2;
mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
updateSerial();
mySerial.println("AT+CMGS=\"+917602304567\"\r"); // Replace x with mobile number
updateSerial();
mySerial.println(str3);// The SMS text you want to send
updateSerial();
mySerial.println((char)26);// ASCII code of CTRL+Z
updateSerial();
mySerial.println("AT+CMGD=1,4"); // AT Command to receive a live SMS
updateSerial();
}
}

}

void modemsetup()
{
  for(int i=0;i<3;i++)
  {
  mySerial.println("AT");          //Once the handshake test is successful, it will back to OK
  updateSerial();

  mySerial.println("AT+CSQ");      //Signal quality test, value range is 0-31, 31 is the best
  updateSerial();

  mySerial.println("AT+CCID");    //Read SIM information to confirm whether the SIM is plugged
  updateSerial();

  mySerial.println("AT+CREG?");    //Check whether it has registered in the network
  updateSerial();

  mySerial.println("AT+SNFS=0");  //Adjust to earphone mode(AT+SNFS=1 is microphone mode)
  updateSerial();

  mySerial.println("AT+CRSL=2");  //Adjust volume, volume range is 0-15, maximum:15
  updateSerial();

  mySerial.println("AT+CMGF=1");
  updateSerial();

  mySerial.println("AT+CMGD=1,4");
  updateSerial();
  }

  mySerial.println("AT+CMGS=\"+917602304567\"\r");
  updateSerial();

  mySerial.println("I am SMS from GSM Module");
  updateSerial();

  mySerial.println((char)26);// ASCII code of CTRL+Z
  updateSerial();

}


texts: What is the point of a adafruit data logger

texts:
In order to play an audio file, I was suggested to get an Adafruit data logger, yet right now I am stuck with the project and I realized that I'm not using the data logger to its full potential.

Yet I am unable to comprehend the purpose of a data logger ; all I'm using it for is to read SD Cards, and I can do that with a SD Card reader. I did read the whole documentation, data sheet, etc, and I can see that it has some cool functions, but my question is still, why data logger?

I know this  might be a stupid question, but I genuinely don't get what the data logger is supposed to be a huge help of. Please help me.


texts: Arduino Pro Mini and Electronic Speed Controller (ESC)

texts:
I want to send servo signal to ESC and Servo with my 3.3V Arduino Pro Mini.

Can the ESC/Servo read 3.3V signal from Arduino Pro Mini? Or do I need to make some level shifter to make 5V signal?


texts: How to adjust Partition Scheme Wemos D1 mini pro?

texts:
I bought myself a WEMOS D1 mini PRO (16MB) for creating a quite large project.
As I'm writing code, my memory is starting to grow.
When I looked at the Flash size in Arduino IDE, the only options I have are

FS 14MB, OTA: 1019KB
FS 15MB, OTA: 512KB

The only things I need in the project is OTA and EEPROM. (no need for SPIFFS)
I looked around on the internet and came on a couple of sites that manipulate the filesystem.
https://robotzero.one/arduino-ide-partitions/
Also on other forums I read that you could modify the LD scripts that Arduino uses.
But I'm not sure how to define the addresses and what to do.
Here is a visual of the config I want.
ORIGINAL

ADJUSTED

Can someone push me into the right direction ?
Thanks in advance.


texts: add ID number to the feather m0 bootloader (flash)

texts:
I'm trying to add a serial number to the bootloader's flash area of Adafruit Feather m0 board. Seems like feather m0 0-0x2000 area on the flash is non writable by the arduino sketch. i wanted to add a serial number to address 0x2000 - 8 on the flash.
The idea is for the data to be included in the bootloader elf\bin so i can easily flash it on devices and later on access it using flash address  (0x2000 - 8) with NVMCTRL.

I've started out with this solution:

downloaded the code from samd21 arduino bootloader github directory and in ./bootloaders/zero edited the boololoader ld script, first the "Memory" section

FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x2000 /* First 8KB used by bootloader */
FLASHID (rx) : ORIGIN = 0x00002000 - 0x0008, LENGTH = 8

Then the 'sections' section:

.id_sec :
  {
    KEEP(*(.myid))
  } > FLASHID

This should have saved some room in the end of the flash for the id. now in the main.c file:

__attribute__ ((section(".myid"))) const unsigned long ID = 0xdead1234;

Which should have saved the 0xdead1234 hex value in the (0x2000-8) address.

The issue is this:
I compiled this code and linked it just fine, got .hex,.bin,.elf files.
If i'm correct (unless they are somehow compressed) i should be able to see the code 0xdead in the binary.
BUT i don't.
After objdump on the binary(any of them) i can't find the 0xde 0xad in any order anywhere.
The arm-none-eabi-size" --format=sysv -t -x build/.elf does not show the new section i added no where.
Also i do wonder, as i said the 0x2000 address on the flash is non writable once i flashed with atmel-ice \j-link even the bootloader code cannot write to it, i did define in the ld script that i want that memory region part of the flash so i do expect that the compiler + linker + jlink flasher will know to write that data to the right place but not sure.

Anyone got some experience with it ? did it before ?


texts: (noob) 2 servos for robot (head & chest) movement at different speeds at once

texts:
I have an Arduino Uno and two Hi-tec Servos HS-40 & 5055 digital that I'm using for a basic robot build. I'm trying to have 1 servo(HS-40) turn the head back and forth (left to right) slightly faster than other servo (HS-5055) controlling the upper torso. I would like to have each servo working at the same time but not at the same speed without waiting for 1 servo to complete it's movement. I tried a sketch with a delay of 45-50 which seems to work fine for the movement speed and 0-75 degrees is ideal for the head travel and 0-65 degrees for the torso travel. I would like to have this movement to be repeated continuously so the robot mimics like his is looking side to side or left to right naturally. Please help as I tried many sketches but can't find one that works like this. I tried modifying other codes but can't get them work. Any help will be greatly appreciated.
How do modify this code so just the second servo runs at 40 which will slow down just enough? Also this is not my code, but it's one that seems to be close to what I'm trying to do.
#include <Servo.h>

Servo servo1;
Servo servo2;

int i = 0;

void setup() {
  servo1.attach(8);
  servo2.attach(9);

}

void loop() {
  for (i = 0; i < 70; i++) {
    servo1.write(i);
    servo2.write(i);
    delay(50);
  }
  for (i = 70; i > 0; i--) {
    servo1.write(i);
    servo2.write(i);
    delay(50);
  }

}


texts:
I have a small piece of code here that I hope to run on Arduino. Basically what this code is doing is, it takes a nibble from the user, appends a startbit to it, and transmits the code through a transmitter module. The receiver end receives the bits and checks if startbit is being received. If startbit is not being received, then it prints out whatever was transmitted. If startbit is received, then it doesn't print the startbit, just the nibble all in one line.

My question is: is it convention/clever to use the bool array or should I not do that? Second, is there a way to make my code more efficient? Where can I clean it up? Also, is my code legible or very convoluted?

#include <Arduino.h>
#include <WirelessComm.h>

int tx_pin;
int rx_pin;
WirelessComm::WirelessComm(int rxPin, int txPin)
{
    pinMode(rxPin, INPUT);
    tx_pin = txPin;
    rx_pin = rxPin;
}

int countDigit(long n)
{
    int count = 0;
    while (n > 0)
    {
        n /= 10;
        count++;
    }
    return count;
}

void getDigit(bool *data, long num)
{
    int cd = countDigit(num);
    long shift = 1;
    for (int i = 0; i < cd; i++)
    {
        data[i] = (num / shift) % 10;
        shift *= 10;
    }
}

int WirelessComm::writeTx(long nibble)
{
    int i;
    bool data[11]; // warning: I didn't check for buffer overrun!
    int32_t startBit = 110101L; // larger than 32767, so cannot be in int
    if(nibble != 0)
    {
        int sbLen = countDigit(startBit);
        for (int i = 0; i < (int)(sizeof(data) / sizeof(data[0])); i++)
            data[i] = 0;
        getDigit(data, startBit);
        getDigit(data + sbLen, nibble);
    }
    else
        return -1;

    for(i = 0; i < 10; i++)
    {
        if(data[i] == 1)
        {
            digitalWrite(tx_pin, HIGH);
        }
        else
        {
            digitalWrite(tx_pin, LOW);
        }

    }
    return 1;
}

int WirelessComm::readRx(long nibble)
{
    bool first = 0;
    bool second = 2; //initially set to some random value
    bool third = 2;
    bool fourth = 2;
    bool fifth = 2;
    bool sixth = 2;
    bool counter = 0;
    bool val = 0;
    while(true)
    {
        first = digitalRead(rx_pin);
        if(first == 1);
        {
            second = digitalRead(rx_pin);
            if(second == 1)
            {
                third = digitalRead(rx_pin);
                if(third == 0)
                {
                    fourth = digitalRead(rx_pin);
                    if(fourth == 1)
                    {
                        fifth = digitalRead(rx_pin);
                        if(fifth == 0)
                        {
                            sixth = digitalRead(rx_pin);
                            if(sixth == 1)
                            {
                                while(counter < 4)
                                {
                                    val = digitalRead(rx_pin);
                                    Serial.print(val);
                                    counter++;
                                }
                                Serial.println();

                            }
                            else
                                Serial.println(first);
                                first = digitalRead(rx_pin);
                        }
                        else
                            Serial.println(first);
                            first = digitalRead(rx_pin);
                    }
                    else
                        Serial.println(first);
                        first = digitalRead(rx_pin);
                }
                else
                    Serial.println(first);
                    first = digitalRead(rx_pin);
            }
            else
                Serial.println(first);
                first = digitalRead(rx_pin);
        }
        else
            Serial.println(first);
            first = digitalRead(rx_pin);
    }
}


texts:
I am currently carrying out a project where I am using an Arduino Mega2560, to recover data from two ultrasonics sensors (HC-SR-04).
For the purpose of my project, I must add HTTP requests to this, unfortunately the Arduino Mega2560 does not allow me to connect to a WIFI.
I contacted my school, they gave me an ESP32, but as far as I understand I will not be able to connect it to my Arduino 2560?
I also have an esp8266, I found the documentation for the code, but despite many attempts (ex: connecting ESP8266 to mega 2056), I cannot connect, I cannot connect it to my MEGA 2560.

Anyone have any ideas / advice?

Regards,
David


texts: can Arduino IDE link to other libs / files in other directories?

texts:
can Arduino IDE point to a file in another directory? If yes how?
With my code

../../main.h

the compile fails.

Error:

In file included from D:\Eigene Dateien\Entwicklung\SIGNALDuino_MR\src\arduino-ide\SIGNALDuino\SIGNALDuino.ino:1:0:

main.h:1:1: error: expected unqualified-id before '.' token

 ../../main.h

 ^

exit status 1
expected unqualified-id before '.' token

--------------- structure ------------------

TEST
  |--main.h
  |-----Ordner 1
             |-----Ordner 3
                       |--files.h
  |-----Ordner 2
             |-----Ordner 4


texts: error while loading libtinfo.so.5 - SOLVED

texts:
I just installed the 1.6.7 version and want to upload it a sketch to Arduino UNO hardware. I get error message:

  /home/pali/Irataim/TarBalls/Arduino/arduino-1.6.7/hardware/tools/avr/bin/avrdude: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

I'm on Gentoo linux operating system.

How can I solve this problem?

By following this link:

https://forums.gentoo.org/viewtopic-p-7815500.html?sid=f67283068e3655b2f9e259a2097efef6
I just add tinfo USE flag to ncurses package, re-emerged it and can run Arduino IDE that I emerged from Gentoo repository.


texts:
At school, our teacher always taught us to use .hpp (C++ Header files) with our .cpp (C++ files). But Arduino seems to use .h files (with .cpp links?).

When someone is programming in C (without C++ compiler) they have the chance to get linked to a .cpp file through a .h file?

So why isn't a .cpp file always with a .hpp file?
What are the drawbacks of using .hpp files with your .cpp files?

This is not to start a discussion on what's best, please provide an answer with arguments that are not based on "what you like to do more".


texts:
I'm trying to use a Wemos D1 mini as a smart button that will boot up, perform a task, and then shut back down. I'd like to do this as a true power off as opposed to any sort of sleep mode.

I'm hoping I can do something similar to this post https://www.esp8266.com/viewtopic.php?f=11&t=4458

Tie RST pin to a Low GPIO pin so that it doesn't boot
Push a button that will run 3.3v to RST pin to make it go high and cause a boot up
Flip the GPIO pin that is tied to RST to high so that it stays running when button is no longer pressed
Run some code and flip GPIO back to LOW shutting down

Things I've tried:

Tie to GPIO15 (D8) - This stops the boot and starts booting when button is pressed but never finishes booting up. I'm assuming I am causing D8 to go high by pressing my button and interfering with the boot, but honestly not sure
Tie to GPIO4 or 5 (D2, D1). This doesn't prevent boot.
I've also tried #2 with a pull down resistor on the GPIO pin, but that doesn't seem to work either

Any help would be much appreciated.


texts: Difference between void setup() and void setup(void)

texts:
As it says in the title. I have been searching but I cant seem to find the answer.

What is the difference between void setup() and void setup(void) as well as void loop() and void loop(void)?


texts:
I have a string of 10x DS18b20 sensors on a single two wire line (parasitic power). Below is a table of the sensors, Where they are located on the wire, and in what order where they discovered.

Serial              Order on wire*   Order discovered
286305560100002c    1                7
28a158610100006a    2                3
28ad48610100006b    3                6
2851ae60010000ad    4                4
289b426101000089    5                8
28cd1161010000ce    6                5
2864026101000030    7                1
280c766101000026    8                2

I read this document on how the OneWire discovers sensors on the bus. https://www.maximintegrated.com/en/app-notes/index.mvp/id/187

My question: Is there a way to detect the order of the sensors on a wire?


texts:
I tried a basic Blink example and I found a strange case where :

Works

Does not work

Can someone explain me what is happening ?


texts: Measuring time between two photoresistors and printing time on lcd

texts:
I am working on a project that is supposed to record the time difference between two photoresistors that are 4in apart. The photoresistors are sensing the passing of water or other liquids on a chute/ramp.

The liquids range from water to milkshakes so the time difference shouldn't be more than 2 or 3 seconds at most (I would think). I'm okay with the accuracy being off by a a few tenths of a second.

I am using Photo cell (CdS photoresistor) for my project.

I have looked online and haven't seen a similar project. I want to be able to display the time difference on a lcd.

I have my lcd up and running but I'm not sure how to code the time difference. My photoresistors are connected to A0 and A1 and I am using digital pins 7-12 for the lcd. If anyone has any advice that would be very appreciated!

I'm sure I missed something so ask any clarifying questions


texts: Arduino Mega vs. RasPi Pro Cons in 3D Printing

texts:
Recently I tooked a look at cheaper China 3D Printers and noticed they're all based on RepRap (mostly using Ramps for the electronics part) and the next day i saw a 2d Plotter based in the pi. Then I asked myself why the Pi isnt used in 3d printers.

Question:
Why is the Arduino Mega/Due more used in 3D Printing than the RasPi? What are the Pro's and Con's for 3D Printing on the two systems?


texts:
I am currently trying to build a line follower robot that is designed to solve maze. This maze has a loop, thus it needs to know distance it already travelling (or at least I assume so, please let me know otherwise).

I am aware of a rotary encoder motor from Polulu (for example) but it's not available in my country and shipping price is too expensive.

So I need to find way around it. Should I use Stepper motor? Is there any other way? Thanks in advance.


texts:
Here I wrote code for my weighting scale measurement. In which I added an on/off switch for my LCD display. But in defined delay time my LCD is a blink and I do not want it. I want my LCD switch on/off work on 1000 delay time effectively.
How I can do this. please guide and edit my code.
#include "HX711.h"
#include <LiquidCrystal_I2C.h>

HX711 scale(4, 5);//(DT, SCK)
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int buttonPin = 2;
int buttonState = 0;

float calibration_factor = -55;
float units;
float ounces;
float in_kg;

void setup()
{
  //  Serial.begin(9600);
  lcd.init();
  lcd.noDisplay();
  lcd.noBacklight();

  lcd.setCursor(0, 0);
  lcd.print("Calculate Weight");
  lcd.setCursor(0, 1);
  lcd.print("Loading...      ");
  delay(3000);

  scale.set_scale(calibration_factor);
  scale.tare();

}

void loop()
{
  units = scale.get_units(), 10;
  if (units < 0)
  {
    units = 0.00;
  }
  ounces = units * 0.035274;
  in_kg = units / 1000;

  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH)
  {
    lcd.setCursor(0, 1);
    lcd.print("Reading: ");
    lcd.print(in_kg);
    lcd.print("kg");

    lcd.backlight();

    // Display the text on the LCD.
    lcd.display();

    delay(3000);
    lcd.noDisplay();
    lcd.noBacklight();

  }

}


texts: Can I control LED brightness with potentiometer without any code, as well as reading the potentiometer value?

texts:
I am just getting back into electronics and have started to play around with making my own button box.
I am trying to control an LED's brightness using a potentiometer, while also reading the potentiometer's value with the Arduino's analogue pin. I want to limit the number of pins I am using for things because I have lots of buttons that will need to be hooked up, so I am trying to control the LED without any code.
I have put together the following circuit (sorry, not my tidiest diagram. I am also using a Pro Micro rather than a Leonardo, but I didn't think that would make any difference :) ).

This works to a degree. I am able to adjust the LED brightness using the pot, and I do get a reading on the Arduino from the pot, however, the reading does not go up linearly as I would expect. It seems to get to about 500 out of 1023 at 4/5 of the rotation and then jumps up to 1023 within the last 1/5.
Could someone explain why this happens, and if it is even possible to do what I am attempting?
Thanks in advance!


texts: Sampling rate of multiple analog pins on Arduino

texts:
as I checked on Arduino website, they mentioned all boards: UNO, Nano, Mini, Mega have maximum sample rate 10kHz for each analog pin. So my concern is:
1) is there any difference between sampling rate when reading a single analog pin and multiple analog pins? For example, if we read only 1 analog input, maximum sample rate can reach 10kHz. How about maximum sample rate when we want to read 6 analog inputs? Maximum sample rate will be 10kHz or (10/6)kHz? Can we do analog input reading simultaneously or not?

2) What if I want to get sampling rate at least 1kHz for each Arduino board (assume 5 analog inputs)?

3) In case we need to connect several Arduino boards via I2C or SPI protocol, is sampling rate related to these 2 protocols?


texts: How to increase the frequency of data transmission of SIM900A GSM Module connected to Arduino Uno?

texts: I have a SIM900A GSM Module hooked onto an Arduino Uno board. The Arduino is connected to a MPU6050 Accelerometer which is constantly monitoring data at 1 second interval. I am trying to transmit the gathered data to ThingSpeak server. I have successfully established the connection with the server and the transmission is occurring. However, the interval between two transmitted readings are very large, varying between 1 to 3 minutes. That interval is too large to use the data. Is there any way I can enhance the transmission frequency so that the data points are close enough? At least to a few seconds distance?


texts: How to recreate this basic ALPS switch board in Arduino?

texts:
I want to recreate this existing ALPS switch board (the board on the left) in Arduino, so I can control the switches (and 3 memory + 1 menu buttons) from my laptop. The ALPS switch board connects to a controller board (PSM) with relays, microprocessor, and DC motors connected to it.

The idea is to use Arduino to completely replace the ALPS switch board, while still preserving the controller board connection and current wiring and connector (16 pins + 2 empty pins).

Is there a way I can just connect the 16-pin connector directly to header pins on a certain Arduino variant? And program the individual pins, to replicate the manual switch input + 4 buttons?

See pin diagram attached (seen from the other end of the wiring, on the controller board side), where I get a little bit confused about terminal #C4 - #C7.

If easily possible, I want to use the controller board power, not the Arduino power.
I’m also not sure about what the 2000 Ohm resistor on the left side does exactly.

Edit 1:
Hopefully the new picture above clears things up a bit. The switch board connects to a PSM (Power Seat Module), which controls the DC motors of an early 2000s car power seat (don't think the OEM matters here). I want to control the PSM with my Arduino (so I don't have to use the ALPS board anymore). In other words, I have to replicate all the functionality from the ALPS board with my Arduino.

Edit 2: A picture of underside of Alps board:

Edit 3:
The P/N for the switch board is: ALPS ANJ971038D RH DR. And for the PSM (which includes the relays): ALPS ANV971018A. There is no public documentation that I found for any of the 2 boards. The pinout diagram above is from the dealership, but I'm not allowed to post further details about it.

Here are the results of what I measured myself using my multimeter. When the switch board is powered from the PSM I measured 4,5V on the + and - of the 4 memory buttons in neutral position. By pressing a memory butting the voltage drops to 0V. The + and - on the white switches measured 11,90V in neutral position. According to the pinout diagram the voltage is supposed to drop to 0V, but this didn't happen when I moved the switch while measuring. I also measured a resistance of 1490 Ohm between pin 2 and 5 of a white switch (so the neutral position), while the switch board was being powered! No resistance when the board is disconnected from the PSM.

I also measured pin #C4 and #C6/7 right from the connector, and I got 0,99V. #C5 and #C6-7 gave me 2,95V. Pin #C4 and #C5 are connected to the resistor (R1).

The switches are all momentary switches.

2 pictures of sketches/measurement results:


texts: Compilation error using arduino-mk on arch Linux (undefined reference to __dso_handle)

texts:
I'm compiling a simple sketch that reads values from an analog input
and activates a buzzer on a digital input.
working on an Arduino uno.
the sketch compiles and runs fine on windows and arch linux using the Arduino
IDE.

I recently tried to start working with Arduino-mk, I tried to compile the said sketch and got the following compiler error (analogVal is the variable holding the analogRead):

/usr/bin/avr-gcc -mmcu=atmega328p -Wl,--gc-sections -Os -o /home/niv/Gits/bin/uno/maglove/maglove.elf

~/Gits/bin/uno/maglove/maglove.ino.o ~/Gits/bin/uno/maglove/libcore.a  -lc -lm
/home/niv/Gits/bin/uno/maglove/maglove.ino.o: In function `_GLOBAL__sub_I_nothing':
maglove.ino:(.text.startup._GLOBAL__sub_I_nothing+0xc): undefined reference to `__dso_handle'
maglove.ino:(.text.startup._GLOBAL__sub_I_nothing+0xe): undefined reference to `__dso_handle'
maglove.ino:(.text.startup._GLOBAL__sub_I_nothing+0x18): undefined reference to `__cxa_atexit'
/usr/bin/avr-ld: /home/niv/Gits/bin/uno/maglove/maglove.elf: hidden symbol `__dso_handle' isn't defined
/usr/bin/avr-ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
/home/niv/Gits/Arduino-Makefile/Arduino.mk:1416: recipe for target '/home/niv/Gits/bin/uno/maglove/maglove.elf' failed
make: *** [/home/niv/Gits/bin/uno/maglove/maglove.elf] Error 1
make: Target 'all' not remade because of errors.

I am not very experienced with Arduino yet, and google has failed me in finding this error or any keyword from it in the context of Arduino uno.

thanks.


texts:
working on a project to make a rover-like vehicle move, and was running into a problem where our stepper DC motors are overheating. I suspect that it's because of the multiple "if" branches we're running through a loop in our code. Was wondering if anyone had any ideas to make this more efficient?
void loop() {
cstore=pulseIn(A3, HIGH);         //values for our radio controller to communicate with board (Arduino UNO)
lstore=pulseIn(A2, HIGH);
rstore=pulseIn(A0, HIGH);

rmove = map(rstore, 994,1872, -255, 255); //center over zero
//rmove=map(rmovepre, -255,255, -500, 500);

lmove = map(lstore, 1007,1989, -255, 255); //center over zero
lmoveinv=-1*lmove;
rmoveinv=-1*rmove;

//Serial.println("CH1   CH2   CH4");
//Serial.print(cstore);
Serial.print("   ");
Serial.print(lmoveinv);
Serial.print("   ");
Serial.print(rmove);
Serial.print("   ");
Serial.println(cstore);

//valid pwm values

/*What we're doing here is determining whether we want to move
forward or backward*/
if(rmove>0) {
  Motor1_Forward(rmove); // back right
  Motor2_Forward(rmove); // front right
}

if(lmoveinv>30) {
  Motor3_Forward(lmoveinv);
  Motor4_Forward(lmoveinv);
}

if(rmove<-70) {
  Motor1_Backward(rmoveinv);
  Motor2_Backward(rmoveinv);
}

if(lmoveinv<-30) {
  Motor3_Backward(lmove);
  Motor4_Backward(lmove);
}

if(cstore<1200) {
  Motor1_Brake();
  Motor2_Brake();
  Motor3_Brake();
  Motor4_Brake();
}


texts: Getting error while using conditional preprocessor to define macro

texts:
int parity = 1;
// DATA, PARITY, and STOP BITS SETTINGS
#if parity == 1
    #define PARITY SERIAL_8N1
#elif parity == 2
    #define PARITY SERIAL_8O1

void setup()
{
  Serial.begin(9600, PARITY)
}

void loop()
{
  Serial.print(parity);
  Serial.print("PARITY");
}

#endif

Error -
/home/akshulg/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/main.cpp:43: undefined reference to `setup'
/home/akshulg/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/main.cpp:46: undefined reference to `loop'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

If I am using this code -
int parity = 1;
// DATA, PARITY, and STOP BITS SETTINGS
#if parity == 1
    #define PARITY SERIAL_8N1
#elif parity == 2
    #define PARITY SERIAL_8O1
#endif
void setup()
{
  Serial.begin(9600, PARITY)
}

void loop()
{
  Serial.print(parity);
  Serial.print("PARITY");
}

Error -
error: 'PARITY' was not declared in this scope
   Serial.begin(9600, PARITY)
                      ^
exit status 1
'PARITY' was not declared in this scope


texts:
I have a sensor that requires used of 5V as input to Vcc. But I dont see any 5V output pins on the NodeMCU 1.0(12E). Is there a way I could get 5V output pins?

Its not a duplicate question. I want a 5V output and not provide 5V input to NODEMCU.


texts: ARDUINO IDE debug level for stack trace only (nodeMCU 1.0)

texts:
What is the minimum debug level (TOOLS tab) which will display the stack trace on crash?

I would like to reduce information clutter in the serial monitor.

I understand that debug port must point to my serial monitor.

In case it makes a difference, it is a NodeMCU, running C++, in Arduino IDE on a Ubuntu 16.04 machine.


texts:
I am using an ESP8266-12E with a PCF8547.
I have managed to turn on and turn off LEDs using these two things.
I am using these three commands to do it.

 Wire.begin(SDA_PIN,CLK_PIN);
 Wire.beginTransmission(0x20);
 Wire.write(~((uint8_t)1<<cnt));
 Wire.endTransmission();

The problem I am facing here is: I am using 4 LEDs and I am only able to turn on one LED at a time. When I turn on another, all the LEDs turn off - in short, the LEDs or the PCF8547 do not preserve the state.

I want to toggle on the LEDs without disturbing the other's state.
How can I do it?
I think, I need more knowledge about the write function, don't I?

Update:

I have already connected A0, A1, A2 to ground. This is the function I use now to toggle the LEDs.

void enlight(int cnt)
{
  if (cnt == 1)
    value = value | 1<<cnt;
    if (cnt == 2)
      value = value | 2<<cnt;
    if (cnt == 3)
      value = value | 3<<cnt;
    if (cnt == 4)
      value = value | 4<<cnt;
    value = ~value;
    Wire.begin(SDA_PIN,CLK_PIN);
    Wire.beginTransmission(0x20); Wire.write(value);
    Wire.endTransmission();
  }

but when I turn off/on any other LEDs they also toggle, which I don't want.


texts: Avoid the 10 attempts of Avrdude when programmer is not responding

texts:
Sometime I update my sketch in the Arduino environment, and when I click on the transfer arrow but forget to plug my arduino (I'm using the UART in my project so every time I need to plug/unplug some wires) it's a drama, avrdude throw this for at least 2 minutes :

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

It's a real pain because I can't stop avrdude when this happens.
Is there a way to configure the Arduino environment to disable it?


texts: Random numbers being printed back after entering data

texts:
I am currently working with an Arduino Micro / Linduino and making a program based on a lot of switch statements to execute certain functions that will be passed to a microprocessor (LT2974) on a board serially. For the most part, all of the functions I have work, except there is one that I am trying to determine if it is my program that is causing issues, or the Linear Tech libraries that are provided. Upon research, I did discover something strange in my code that I cannot explain.

Here is a quick snippet of my code:

unsigned long serialdata;
int inbyte;

long getSerial()
{
  serialdata = 0;
  while (inbyte != '/')
  {
    inbyte = Serial.read();
    if (inbyte > 0 && inbyte != '/')
    {
      serialdata = serialdata * 10 + inbyte - '0';
      Serial.print(serialdata);
      Serial.print("test \n");
    }
  }
  inbyte = 0;
  return serialdata;
}

void loop()
{
  getSerial();
  // Switch statement represents Slot choices
  switch (serialdata)
  {

    case 1:
      {
        commands(Slot1);
        break;
      }
    case 2:
      {
        commands(Slot2);
        break;
      }
    case 3:
      {
        commands(Slot3);
        break;
      }
    case 4:
      {
        commands(Slot4);
        break;
      }
  }
}

I have left out the following switch statements that are found in the commands function as they are not where the issue lies.

For some reason, when I pass data through to the Arduino, and then go to reprint it out with my Serial.print command in getSerial(), there is an additional number printing, and I believe the issue to lie here.

So, for example, if I type "/1/" (the slashes were used to pass multiple variables as shown in the function, but I'm only passing one for now), the Arduino reponds with:

1test
4294967268test

here is "/2/"

2test
4294967258test

and here is passing multiple variables with "/2/9/"

2test
9test
4294967258test

All of the values I just showed you do not correspond to any of my switch statements implemented, and so no actual data is being returned besides the print command from getSerial(). So can anyone explain what is going on here?

EDIT: I added the data types of serialdata and inbyte to the top of the post.


texts: I am having an issue with the a 4×4 keypad. It usually works fine but sometimes the keypad stops reacting or no key is pressed but it still shows a random keypress on the LCD. The only solution is to unplug and plug again. I thought it may be the length of the wires for the keypad. I uses 3 ft wires from the keypad to the Arduino. Has anyone faced similar issues?


texts: Find public IP address of ESP32 using Arduino IDE

texts: I am currently working on a project which implements communication between two ESP32 boards over the Internet. In my project, I want to get unlimited range communication by connecting one ESP32 (as server to get HTTP request) to one router and the other ESP (as client to send HTTP request) to a different router. However this gets me into a complication. I have to give the IP Address of the server ESP to the client one. I can't use the server.localIP() or server.softAPIP() because these methods work only when both ESP's are connected to the same router. There is no method in ESP8266WiFi class that returns the public IP of the ESP32, which is what I need. Is there any another way to find out the public IP of the ESP32? Thanks for the attention.