text:
Is it possible to use I2C and SPI ons the same Clock line?
I'm trying to connect an I2C OLED display and an n RF24L01 WiFi module to an ATTiny85. But I only need 1 extra pin. Is it possible to use the same clock wire/pin for the I2C and SPI device? Maybe with some extra code? Thanks a lot!

Do you have CS pin? Then yes, easily. When the SPI device is deselected, it doesn't care what you put on SCLK and the I2C will get it normally. The other way around, the I2C device doesn't have a CS and will listen to its address byte on the I2C SCL and SDA lines.. If SDA is seperate to the SPI bus, it will just read 0... and not do anything, even if there's a clock.

Yes, in theory it is possible. You can use the scl for other things as long as you keep the sda high. The scl is a input clock for most i2c devices. I assume that the display itself does not pull the scl low. Changing between a open-collector and a digital ttl signal for the scl should therefor not be a problem. If the display has a microcontroller for i2c, then it might pull the scl low. Is the USI used for the i2c bus? Then there might be a shortcut when the SPI library keeps the scl high and the USI/I2C pulls it low. Can you share chipselect with scl? Then you can release the scl pin.

@MaximilianGerhardt it is about the start condition for i2c. When sda does not turn low, there is no start condition and the i2c devices do nothing.

@Jot oh right, you'd have to take that into account, too..

Perhaps it is safer to do Wire.begin, then normal i2c, then Wire.end() and the same for the spi.

Can Software I2C be a solution for this? If so, how do I need to program this so it can communicate with the ssd1306 oled library?

I'll suggest you to use Mode-2 or 3 of SPI, as in that case, SPI device will get clk pulses only when you have LOW to HIGH transition, & thus, the I2C device will not get the start bit condition ( SCLK should be HIGH and SDA should have a falling edge for start bit of I2C frame). When you need to communication with I2C device, make SCLK as HIGH and start the I2C frame which will result in SPI device to wait for  the CS pin. Also, try pulling SCLK line with CS pin line as this would pull it down for SPI mode, & when HIGH, it will enable I2C & SPI will not have CS signal for its functionality.


text:
How to interface Arduino with NXP PCA8561 LCD segment driver?
I've just bought few NXP PCA8561AHN LCD segment drivers to do some tests which unfortunately did not went as expected.
I'm familiar with expanders and segment LED displays but LCDs seem to be way more complicated than I thought and there are no libraries or articles to start with.
According to the datasheet, everything is connected correctly, as follows:

VLCD: +3.3V
VDD: +3.3V
VSS: GND
RST: pulled down by a 1K resistor
A0: unconnected
SCL: pulled up by a 1K resistor and connected to A5/SCL on MCU
SDA: pulled up by a 1K resistor and connected to A4/SDA on MCU
PORE: unconnected
SEG0 to SEG13: LCD segments
COM0: LCD pin 1 (backplane #1)
COM1: LCD pin 18 (backplane #2)

PCA8561 draws 35uA when RST is pulled down so it seem to be "active".
Here's how I've tried to initialize the i2C communication with the driver:
#include <Wire.h>

#define address 0x38

const byte numbers[10] = {
  B01000000,
  B01111001,
  B00100100,
  B00110000,
  B00011001,
  B00010010,
  B00000010,
  B01111000,
  B00000000,
  B00010000
 };

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

  Wire.begin();

  Wire.beginTransmission(address);
  Wire.endTransmission();
}

void loop() {

  Wire.beginTransmission(address);

  Wire.write(numbers[5]);

  while (Wire.available()) {
    char c = Wire.read();
    Serial.print(c);
  }

  Wire.endTransmission();
  delay(250);
}

PCA8561 datasheet
PCA8561 pinout

    .
LCD pinout

Update
void setup() {
  Wire.begin();

  Wire.beginTransmission(address);

  Wire.write(0x00);
  // Wire.write(00000000);
  Wire.write(00101100);
  Wire.write(0x0);

  Wire.write(0x01); // Display_ctrl command (address 01h)
  // Wire.write(00011100);
  Wire.write(010); // frame frequency selection: 96Hz

  Wire.write(0x02); // Display_ctrl_1 command (address 02h)
  // Wire.write(00001100);
  Wire.write(11); // static mode

  Wire.endTransmission();
}

void loop() {
  Wire.beginTransmission(address);

  /*
     Static drive mode
     Using a single backplane, COM0
  */
  Wire.write(0x04); // SEG0 to SEG 7
  Wire.write(B11111111); // all segments ON
  Wire.write(0x05); // SEG8 to SEG15
  Wire.write(B11111111); // all segments ON

  Wire.endTransmission();
}

Few things:

Wiring - the datasheet says in 8.3.3:  "At power-on the PCA8561 can be reset (...) by pulling pin RST low". By pulling it to GND you asking your LCD to stay in Reset state.
You miss display initialisation. Where is your settings for Device_ctrl,  Display_ctrl_1,  Display_ctrl_2 registers?

@smajli , first of all, thank you for taking your time to read the datasheet, I really appreciate the effort. Second, I've managed to write some code for a correct(i hope) start sequence and finally, i can see 10 segments lit on LCD. I think there are some pads unsoldered which I will take care of later. Still not sure if the start sequence can be written in a more efficient way so if there is something I can improve, please let me know. Thanks a lot for your help

good effort. I'm glad I could help. Little things for your code: you may use #define Display_ctrl 0x01 at the beginning of your code, and later instead Wire.write(0x01) place Wire.write(Display_ctrl). Make it with all display commands and registers you are planning to use. This will make your code human friendly.  Later you may think about placing these into separate file thus making it ready for writing a library.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
How to get the weather kit with anemometer working using arduino (UNO)?
I tried to build a weather station with anemometer and My setup is,
SwitchDoc Labs' anemometer kit (which is equivalent to sparkfun anemometer kit) connected to the grove weather-pi board with rtc clock DS3231 installed on which is connected to arduino UNO.
According to http://www.switchdoc.com/wp-content/uploads/2016/07/WeatherBoard_CurrentSpecification.pdf and their official tutorial https://www.switchdoc.com/2015/01/weather-arduino-weatherpiarduino/, if I use grove weather-pi board's JP2 connections to connect to the UNO/Mega2560 board then it suggests as following (in my case its UNO)
diagram 1
diagram 2
GroveWeatherPi_board    Mega        Uno     Units
    JP2/1 ->            A0          A0      WindVane
    JP2/2 ->            D2          D3      RainBucket
    JP2/3 ->            D5          D2      Anemometer
    JP2/4 ->            GND         GND     GND

And the supposedly working sketch/library is https://github.com/switchdoclabs/SDL_Weather_80422 which only compiles on arduino-IDE without issue if I use the fork https://github.com/soligen2010/Adafruit_ADS1X15 instead of the original https://github.com/adafruit/Adafruit_ADS1X15 with it but even then the wind-speed and wind-direction unit or to say the whole anemometer part just do not work or in other words, do not give any reading. I have tested the units individually up to the arduino pins with LED light on breadboard, they are sending signals/responding and also mounted the whole project on a Mega2560 as well but results remained unchanged.
I am assuming the pin-outs defined in the https://github.com/switchdoclabs/SDL_Weather_80422 are messed up then but how to redefine it in the sketch/library because in the ino sketch file, these are the pin-out definitions for primarily Mega2560
#define pinLED     13  // LED connected to digital pin 13
#define pinAnem    18  // Anenometer connected to pin 18 (not used in the diagram!) - Int 5 - Mega   / Uno pin 2
#define pinRain    2   // Anenometer connected to pin 2 - Int 0 - Mega   / Uno Pin 3
#define intAnem    5   // int 0 (check for Uno), according to the above two diagrams' comparison, for UNO this pin also goes to the pin 2
#define intRain    1   // int 1 (not used in the diagram! Then why? Its a TX pin)

Where the pinAnem and intAnem both indicates pin 2 for UNO according to the above two diagrams.
When I connect the I2C vcc pin from grove-weather-board to UNO's 5 volts instead of 3.3 volts as shown, the wind direction gets fixed but still no wind-speed reading.
So what are the corrections I need to do in the SDL_Weather_80422 library or in the connection diagram in this case?

This sketch successfully computes only the wind direction though https://github.com/sparkfun/Weather_Shield/blob/master/Firmware/Weather_Shield_Weather_Station_V12/Weather_Shield_Weather_Station_V12.ino after disabling the extra headers.

why do you feel that you need to modify the library??

@jsotola according to any of the diagrams above, have you noticed any A0 definition in the library? I don't, that's why.

this library https://github.com/switchdoclabs/SDL_Weather_80422 (last link in your question) has this command line in the example sketch SDL_Weather_80422 weatherStation(pinAnem, pinRain, intAnem, intRain, A0, SDL_MODE_INTERNAL_AD); .......... A0 is the analog pin for the direction data ..... the other two data pins are also represented

both the anemometer and the rain bucket sensors are simple switches ..... write a simple sketch that reads the switch state and light LED (pin13)  if the switch is activated and turns off LED if switch is not activated...... do that for each of the switches separately

the http://cactus.io/hookups/weather/anemometer/davis/hookup-arduino-to-davis-anemometer-wind-speed sketch reads the anemometer's wind_speed just fine, so it complements the missing functionality of https://github.com/switchdoclabs/SDL_Weather_80422.

According to the above setup only rain bucket unit works.
And as jsotola mentioned both the anemometer and the rain bucket sensors are simple switches, so a simple sketch can be written that reads the switch state and light LED (pin13) if the switch is activated and turns off LED if switch is not activated and that can be done for each of the switches separately.
But instead I took a shortcut.
Fixes:

The wind vane part (on analog pin A0) starts working only when I connect the I2C vcc pin to 5 volts pin instead of 3.3 volts pin of UNO.
Had to ditch the https://github.com/switchdoclabs/SDL_Weather_80422 library's wind_speed reading method and adopting and merging into the http://cactus.io/hookups/weather/anemometer/davis/hookup-arduino-to-davis-anemometer-wind-speed code and adding up the wind_gust function from https://github.com/sparkfun/Weather_Shield/blob/master/Firmware/Weather_Shield_Weather_Station_V12/Weather_Shield_Weather_Station_V12.ino makes the anemometer with rain-bucket with the exact same setup fully functional.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
First Arduino Uno - Immediate Problems
I'm new to Arduinos but researched thoroughly before buying one. Just for context I'm an IT Professional with 20 years in the game, I'm comfortable with Linux/Unix, Windows, Raspberry Pi's, electronics, hardware, software and monitoring/switching COM ports.
I've purchased my first Arduino (actually a Elegoo Uno R3 clone) and have just tried it out of the box connected to two different systems; one Windows 7 64bit Enterprise the other Kubuntu. Despite having the correct COM port selected on both I'm getting similar error messages:
**avrdude: ser_open(): can't open device "\\.\COM15": The system cannot find the file specified.**

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

Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Yes I have tried different COM ports.
Yes I have tried turning off Firewalls
Yes I have tried different USB cables.
I have a solid green LED and a intermittently blinking orange LED.
The suggested Troubleshooting guide + many Forum Threads do not seem to cover this exact error I'm encountering - well they do but they tend to be people with the simple issue of them not selecting the correct COM port or having the same COM port tied up with another task. Then choose the correct port and it works. I'm confident I have the correct COM port and when I click Get Board Info it pulls down the correct board information and serial number etc.
On the Linux system I was seeing a similar behavior with slightly different wording: Permission Denied
On my Windows 7 system I run as a Standard User (as one should, not as an Administrator), but regardless I have tried running the Arduino application normally and as an Administrator user but it has the same result. And it seems strange that it encounters the same style of error across multiple different operating systems.
Have I just been really unlucky and got a dud for my first Arduino or am I missing something obvious?
Thanks for your time and help.

refer to the windows device manager ...... does a comport device appear in the device tree when you plug the arduino into the USB port?

You didn't mention drivers in your troubleshooting - have you installed the USB-chip drivers on your PCs? The clone boards come with a different USB <-> TTL Serial chip or firmware (not sure which) than the Italian boards and require CH340 drivers on the PC side to talk to it. (Whereas many OSes include drivers for the FTDI firmware/protocol used on Italian boards). If not, you can find them on the Downloads section of Elegoo's site.

Yes it does, I think you may have missed certain elements of my initial post. I'm very confident with the selection, monitoring and configuration of COM ports.

Thanks @JRobert for that insight. I've tried downloading the CH340 drivers from Elegoo's website and installing those but no change.

@JRobert I think you may have just nailed the problem with your CH340 comment - I didn't think it had worked initially after installing, but after a reboot it began to work on my Win7 64 bit system! Thank you. At least this proves to me that the Uno board is not broken and is worth wrestling with on other operating systems if I have to. Thank you everyone for your time and help.

On Linux "Permission Denied" generally means one of two things:

You're not in the dialout group (or you haven't logged out and logged in since), or
Something else is using the serial port.

For 1:
sudo usermod -a -G dialout ashley
<log out or reboot>

For 2:
The most common culprit is ModemManager. The simplest cure is to uninstall it:
sudo apt-get remove modemmanager

I assume ashley would be your username.

@Gerben No, mine would be matt. Ashley's would be ashley... ;)

OP is on Windows. why an answer for Linux?

@Juraj He's on both Windows and Linux. Read the question: "and have just tried it out of the box connected to two different systems; one Windows 7 64bit Enterprise the other Kubuntu." and "On the Linux system I was seeing a similar behavior with slightly different wording: Permission Denied"


text:
I have this compilation error:
C:\Users\MGMCETIT\Desktop\Dumpster\Dumpster.ino: In function 'void loop()':
C:\Users\MGMCETIT\Desktop\Dumpster\Dumpster.ino:40:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 if(esp8266.find("+IPD,"))

                        ^

did you write the esp8266.find function? if you did, that's a simple fix - though, that's just a warning isn't it? the code still compiles

@JaromandaX it is core Stream class. it is only a warning

I did notice it's just a warning :p @Juraj

It appears Arduino decided that it would be a good idea to use char * instead of const char * for functions that don't modify the parameter. It should always be const char * unless you have a good reason not to.  Silly Arduino.

I have submitted a bug report (gently) berating them.

@Majenko, it is there 8 years. commit comment: "This from Michael's TextFinder library, incorporated into the Stream class: find(), findUntil(), parseInt(), parseFloat(), readChars(), readCharsUntil(), readCharsBetween(), setTimeout()."


text:
Electric meter with Arduino and RS485 module
I'm a Arduino newbie. I have an Electric meter with an RS485 output. I want to get the MeterID value over the RS485 module and the Arduino. I just have document from manufacturer.
Sent by computer : 68 99 99 99 99 99 99 68 01 02 67 F3 C3 16.
Return from meter : FE 68 99 99 99 99 99 99 68 81 08 67 F3 A6 9B 34 4B 33 33 6F 16.

My Arduino code:
#include <SoftwareSerial.h>

#define SSerialRX        10
#define SSerialTX        11
#define SSerialTxControl 3
#define RS485Transmit    HIGH
#define RS485Receive     LOW

SoftwareSerial RS485Serial(SSerialRX, SSerialTX);
byte request[] = {0x68, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x68, 0x01, 0x02, 0x67, 0xF3, 0xC3, 0x16};
int byteRead;

void setup()
{
  Serial.begin(9600);
  RS485Serial.begin(1200);
  pinMode(SSerialTxControl, OUTPUT);
  digitalWrite(SSerialTxControl, RS485Receive);
  delay(20);
  Serial.println("Get Meter Address App");
}
void loop()
{
  digitalWrite(SSerialTxControl, RS485Transmit);
  RS485Serial.write(request, sizeof(request));
  delay(2000);
  digitalWrite(SSerialTxControl, RS485Receive);
  delay(2000);
  if (RS485Serial.available())
  {
    byteRead = RS485Serial.read();
    Serial.println(byteRead, HEX);
  }
}

Serial Monitor show:

I'm using combo like this topic modbus-rtu-controller-monitoring-with-arduino-and-rs485-module. My code is in C# below. I used the code before and it worked fine, but on the computer I use a COM port (Baudrate 1200, data 8bits, Parity EVEN, Stopbit 1) with an RS485-R232 converter:
#Send data
dataOUT = WriteData("68 99 99 99 99 99 99 68 01 02 67 F3 C3 16");
serialPort_Meter.Write(dataOUT, 0, dataOUT.Length);

#WriteData method
private static byte[] WriteData(string hex)
{
return hex.Split(' ').Select(s => Convert.ToByte(s, 16)).ToArray();
}

#Read data
private static string ReadData(SerialPort serial)
{
byte[] buffer = new byte[serial.BytesToRead];
serial.Read(buffer, 0, buffer.Length);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < buffer.Length; i++)
sb.AppendFormat("{0:X2} ", buffer[i]);
return sb.ToString();
}

you don't have delays in C#. why do you have delays in Arduino?

It's still blank

with delay you missed the data. without delay you check too early

Please advise me

Hi Cosi Nguyen. Can you share some details about the electric meter you are trying out this with? Even the document you are referring to can be helpful to understand.

Hi Sumit Panse. My meter is http://electrique.com.sg/?product_cat=amsys. This is private company of my country and document don't public in the internet

Hello all, I figured out the reason is because SoftwareSerial's default library does not support connection configuration. I use CustomSoftwareSerial and fixed it by connecting the required data bit, stop bit, ...

Using readBytes would do the same as your C# code. readBytes is blocking. It will wait for every byte until timeout. Default timeout is 1 second. If the count of bytes is smaller then the size of the buffer, it will wait a second after the last byte received. You can set the timeout with RS485Serial.setTimeout(500); (500 milliseconds for example).
void loop()
{
  digitalWrite(SSerialTxControl, RS485Transmit);
  RS485Serial.write(request, sizeof(request));
  RS485Serial.flush();
  digitalWrite(SSerialTxControl, RS485Receive);
  int recvLen = RS485Serial.readBytes(buffer, sizeof(buffer));
  for (int i = 0; i < recvLen; i++) {
    Serial.println(buffer[i], HEX);
  }
}

It's still blank. I think issue from the sent request ?

You mean i need create another function and call in loop() ?

Thank your advise my new code to fix this problem

#include <CustomSoftwareSerial.h>
CustomSoftwareSerial RS485Serial(SSerialRX, SSerialTX);
RS485Serial.begin(1200, CSERIAL_8E1);

sorry, I overlooked that you set non standard serial parameters


text:
Arduino analogRead fluctuates from sensor unless USB connected
I have an Arduino connected to a 4-20 mA sensor through a current to voltage converter. When connected to the power supply the sensor reading fluctuates, as soon as I also connect it to a USB port it stabilizes and gives a correct reading (tested with other reader).
My main code is:
#include <Arduino.h>
#include "Display.h"

#define MINIMUM_DEWPOINT -100
#define MAXIMUM_DEWPOINT 20
#define AVG_READING_SIZE 20

float dewPoint;
uint8_t recordIndex = 0;
uint16_t analogReadingValue[20];
int sensorMin = 0;
int sensorMax = 1023;
int sensorValue = 0;

void setup()
{
    Serial.begin(9600);
    Display::init();

    for(uint8_t i = 0;i<AVG_READING_SIZE;i++)
    {
        analogReadingValue[i] = 0;
    }
}

uint16_t getAvg(uint16_t *arr,uint8_t numberOfElements)
{
    uint32_t sum = 0;
    for (uint8_t i = 0 ; i < numberOfElements ; i++)
    {
        sum += arr[i];
    }
    return  (uint16_t)(sum / numberOfElements);
}

void loop()
{
    analogReadingValue[recordIndex] = analogRead(A0);
    dewPoint = map(getAvg(analogReadingValue,AVG_READING_SIZE), sensorMin, sensorMax, MINIMUM_DEWPOINT, MAXIMUM_DEWPOINT);
    recordIndex++;

    if(recordIndex==AVG_READING_SIZE)
    {
        recordIndex = 0;
    }

    Display::displayDewpoint(dewPoint);
    Serial.println(dewPoint);
    Serial.println(getAvg(analogReadingValue, AVG_READING_SIZE));
    delay(2000);
}

My circuit diagram is:

Vin starts at 6 V https://store.arduino.cc/arduino-uno-rev3

Thank you, i have swapped Vin for the 5v pin, and now it reads at a constant 1023, while retaining the same behaviour when usb connected

If you feed 5V into Vcc (5V), you must not connect USB. ( Or vice versa :) )

That is my goal, however as I pointed out before, the reading i get when it isn't also plugged into usb is the max value of 1023 constantly, which isn't correct

To add to that the 2 power supplies in the diagram are connected to a switch that connects to mains through a cable

Apparently 5V reference on the 5V pin was the issue as 5V was only supplied to the Vin pin and it was referencing to 0V. Swapping the power supply from Vin to 5V solved the issue

You need a decoupling ceramic capacitor between A0 and GND. 100nF should work just fine.


text:
How to upload sensor data on pubnub IOT with JSON Format?
I am trying to send MPU9250 sensor data to Pubnub IOT platform using node mcu, but not able to do it since the sensor data is not in JSON format. I know about publishing string but don't know about variable.
About Pubnub Library - https://github.com/pubnub/arduino
This is the part which I need help in:-
IMU.readSensor();

PubNonSubClient *pclient = PubNub.publish(pubchannel, IMU.getAccelX_mss());

But above line has error so how do i send imu sensor data to pubnub? All connections are right and sensor is working since I tested it.

Have you tried enabling the debug option? To enable debug logging to the Arduino console, add #define PUBNUB_DEBUG before #include <PubNub.h>

format it in json before sending it out, for small payloads, hand-building JSON isn't that hard.

This is the format which helped me to upload the data successfully. I didn't knew what JSON format was and got stuck. In case if someone stumbles on a similar problem.
char buf[5] = {};

sprintf(buf, "\"%d\"", IMU.getAccelX_mss());

PubNonSubClient *pclient = PubNub.publish(pubchannel, buf);


text:
Light Sensor - how to wait for specific setting then continue on Leonardo?
I have an analog light sensor working on my Micro Pro Leonardo board. I want to reach a part of my code which include keyboard presses where it monitors to see when an LED flashes and then continues the code from there.
Could someone give me a code example of how I can do that?
Currently I'd have something like....
  Keyboard.write(KEY_RETURN);
  delay(800);
  Keyboard.write(KEY_TAB);
  delay(150);
  Keyboard.write(KEY_TAB);
  delay(150);
  Keyboard.write(' ');
    }

//Code here to wait until LED flashes, registers as 30 or less on the light sensor. Then carry on with code below once this happens

  BootKeyboard.press(KEY_LEFT_GUI);
  BootKeyboard.press('r');
  delay(40000);
  BootKeyboard.releaseAll();

etc
I know the light sensor is AnalogValue = analogRead(A0); and I assume it's some kind of "If" statement which loops until the value because less than what is defined but have no idea how this would be written.

Generally you want to avoid delay, and avoid waiting until some external event happens. Both of those things completely lock up the controller until the condition is satisfied. Instead you usually want to check state flags in your loop function, and/or use millis() to see if enough time has transpired.

I know but for a beginner with a script which has about 150 button presses that all have specific and different wait times between each key press, it seems the easiest way to do it. At some point I will revisit the code so I can add a pause button if required, but at the moment it's not the question in hand.

One method:
while (analogRead(A0) < setting){
// sit in this loop taking readings until get one that is >= to setting
}

Thanks @CrossRoads i'll give this I shot, I read it should be a while setting and that < would be used with my number but didn't know how to actually structure this into a line.


text:
Gps with Lora (E32 433T30D)
I want to receive data from GPS Neo 6m to Arduino and want to sent through LoRa (E32 433T30D).
GPS RECEIVE AND LORA SEND code
#include <SoftwareSerial.h>
#include <TinyGPS++.h>

static const int RXPin = 4, TXPin = 5;
static const int loraRXPin = 2, loraTXPin = 3;
static const uint32_t GPSBaud = 9600;
static const uint32_t loraBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
SoftwareSerial lora(loraRXPin, loraTXPin);

void setup(){
  Serial.begin(9600);
  ss.begin(GPSBaud);
  ss.println("KATHE");
  lora.begin(loraBaud);
  lora.println("ASHOK");
}

void loop() {
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0){
    gps.encode(ss.read());
    if (gps.location.isUpdated()){
      ss.listen();
      Serial.print("Latitude= ");
      Serial.print(gps.location.lat(), 6);
      Serial.print(" Longitude= ");
      Serial.println(gps.location.lng(), 6);
      lora.listen();
      lora.print("Latitude= ");
      lora.print(gps.location.lat(), 6);
      lora.print(" Longitude= ");
      lora.println(gps.location.lng(), 6);
    }
  }

  }

LORA RECEIVE CODE is

#include <SoftwareSerial.h>

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

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

  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
    //Serial.println(" ");
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());

  }
}

Here I'm not getting gps data to the LoRa receiver.
Please help me to overcome this problem.

set ss.listen() in setup(). you don't read lora so why listen? are the gps data printed to Serial Monitor?

Thank you for your reply.  No I'm not getting gps data to the serial monitor or through lora. But individual codes if I run, getting data. Only whenever ever I'm clubbing the both codes I'm not getting the data

did you made the change I recommended? (the individual codes don't have two SoftwareSerial instances)

Yes I got it. At sending code no need create another serial port, we can directly use LoRa Rx and Tx to the arduino uno 0 and 1. If I use this method I'm getting data to the Receiver. Thank you so much for your reply.

Lora we can connect directly to the arduino serial ports(0,1)- Lora Tx is connected to the arduino Rx and Lora Rx is connected to the arduino Tx. (this is for receiving data from arduino and must be connected these pins after uploading the code).
(2,3) of other arduino to receive data to arduino from Lora.
For sending there is no code like Bluetooth. And for receiving the following code helps you..
include  SoftwareSerial mySerial(2,3); // RX, TX void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native j for the SoftwareSerial port mySerial.begin(9600); mySerial.println("Hello, world?"); } void loop() { // run over and over if (mySerial.available()) { Serial.write(mySerial.read()); //Serial.println(" "); } if (Serial.available()) { mySerial.write(Serial.read()); } }


text:
nRF24L01 - leaves out end characters during transmission
This is my Master's code.
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>

RF24 radio(7, 8);

const byte address[6] = "00001";
char text[20] = "";
int flag;
char *p;
int i;

void print();
void read();
void rfwrite();
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate(RF24_1MBPS);
  radio.setChannel(1);
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();

  flag = 0;
  p = text;
}

void loop() {

  if (Serial.available()) {
    read();

  }
  if (flag) {
    print();
    rfwrite();

  }

}

void print() {
  Serial.println(text);
  flag = 0;
}

void read() {
  p = &text[0];
  for (i = 0; Serial.available(); p++, i++) {
    *p = Serial.read();
  }
  text[i + 1] = '\0';
  flag = 1;
}

void rfwrite() {

  radio.startWrite(text, strlen(text)+1);

}

Slave code:
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>

RF24 radio(7, 8); //ce,csn

const byte address[6] = "00001";
char text[20] = "";
int  i;

void write_to_array();
void print();
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate(RF24_1MBPS);
  radio.setChannel(1);
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}

void loop() {
  while (radio.available()) {

    write_to_array();
    print();

  }

}

void write_to_array() {
  radio.read(text, strlen(text)+1);

}

void print() {
  Serial.println(text);

}

I edited the code and made it with an array like @Kwasmich said. But now some end characters are not getting printed. When I type 1234567890-= into the transmitter, only 1234567890- gets printed. When I type a new set of characters following that, the missing = gets printed. Also, this happens only on the second transmission after I upload the code to the Arduino. The first set of characters are received and printed correctly. How do I fix this? Will flushing the buffer help(I doubt this because the first transmission is received correctly)?

Your code char text = "" can only hold a single character, not a string. You either need a char array or a char pointer. Likewise sizeof(text) is 1 because this is always a single character.

@ChristianLindig, but that is not the cause of the missing character

Your code currently sends the message only one character at a time. Not sure where the missing character comes in, but I'm pretty sure (from experience), that when you fix the single character issue, your missing characters problem goes away as well.

I cannot test it right now, but I guess the problem is in your slave Code, the initialization of text = "". Therefore the sizeof(text) in the initial run is 0, so something in radio.read(&text, sizeof(text)) will go wrong. Could you check with a diffenent initalization of text, e.g. "0"?

@RJPlog I've tried what you suggested, initializing the text as 'a'. The output remained the same although I think sometimes I noticed that the first transmission after uploading the code to arduino resulted in successfully receiving all the characters, I can't say for sure.

This is not a proper solution explaining why the issue occurred in the first place but merely a workaround to anyone encountering the same problem.
There is another function in the RF24 library called startWriting(). The description in the library was not clear about the differences between this and write(). But I noticed that the last character was missing with the use of startWriting(). So I simply changed
radio.read(&text, sizeof(text));

in the master to
 radio.read(&text, sizeof(text+1));

and voila!
The code now does its intended purpose!!

You are riding on a wave of undefined behavior. sizeof returns the size of the underlying type. In your case char. Which is 1. What you really need is the propper allocated array char text[32] = "" and the required length of the string using strlen(text) + 1. +1 to also transmit the nul terminator of the string.
The maximum string Length that can be transmitted using nRF24L01 is 32 bytes. Because of the mandatory nul termination of a string you can send at most 31 characters as a valid string.
Fun fact: The same limitation of 31 characters applies to file name langths on the classic Mac OS at least up to 7.x and also on the Amiga DOS/Workbench.

Please check the new code in the question. I've edited like you suggested.


text:
Ultrasonic sensor underwater calibration
Does anyone knows how to calibrate AJ-SR04M using the Arduino? I am working on AUV. underwater reading from current code; it is giving continuous 20cm while moving inches. http://shop2.hanjindata1.cafe24.com/product/aj-sr04m-ultrasonic-ranging-module/206/

what is the speed of sound in air? ...... what is the speed of sound in water?

have you tested the sensor in air?

Tested on both. Air was giving me correct results as by using scale but underwater around20cm only despite displacement.

the short answer is, that the minimum measurable distance in water with this sensor is 1 m as sempaiscuba explains in his answer

this sensor do not work underwater is only waterproof.

If I understand your question correctly, your problem is probably that the working range of the AJ-SR04M sensor is 20cm - 500cm.
The sensor uses the same transducer to create the sound pulse and to listen for the echo.  It needs time to switch from one mode to the other, which explains why your sensor can't measure distances of less than 20cm.

The speed-of-sound in water is about 5x the speed of sound in air.  More specifically, at 20 degrees Celsius the speed-of-sound in air is approximately 343 meters per second, while the speed-of-sound in water is approximately 1482 meters per second.
This will cause the sensor to 'under-report' the distance in water.  The minimum distance will also be approximately 5x the minimum distance in air.

As an aside, you will also need to make allowance for the differences in the characteristic impedance and absorption between sound and water.
It's worth reading the paper Underwater Sound by P. Vigoureux (Proceedings of the Royal Society of London. Series B, Biological Sciences, Vol. 152, No. 946) for a discussion of all the factors involved.

and sound travels much faster in water

@Juraj Yes, I was trying to edit the answer to include accurate numbers & a reference.  Not easy on a mobile phone, and even less easy now that the Android SE app is no longer working.


text:
Multiple readings from one change on a light sensor with interrupts
I was trying to make a code which did something every time a light dependent resistor was covered up by using interrupts so I could be running a different code at the same time.
This was my finalised code:
#define LIGHT 2

void setup() {
    Serial.begin(9600);
    pinMode(LIGHT, INPUT);
    attachInterrupt(digitalPinToInterrupt(LIGHT), fall, FALLING);
}

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

void fall(){
    Serial.print("Light Covered!");
    Serial.println();
}

I have tested my ldr circuit (5V into the ldr with a 10k pulldown resistor) and it reliably sits over the digital read boundary so I don't need to use analog read. It also seems to have no bounce as if I read it by outputting a message every time it reads it as high and then waiting until it goes low it only reads once every time I cover it and uncover it. However for some reason the code above which uses interrupts seems to print light covered 3-7 times every time I cover it. I am quite new to arduinos and C although I have used python for a while so sorry if it is a silly noob mistake.

Don't use an interrupt. The arduino environment is not the same as an embedded system. Interrupts can often be avoided. Read the analog value in the loop. Add hysteresis. Do you want to detect a certain fixed value or a change in the value?

do minimum amount of work inside an ISR  ...... raise a flag only ...... print the message inside the loop() block whenever the flag is raised

@Jot I want to detect when the signal gets below a certain bound and the reason I want to use an interrupt is because then I can be monitoring serial while also detecting and doing something every time the signal falls

@jsotola But surely then the code inside the loop() still has to be checking to see if the flag has been raised so if it is doing something like continually checking serial it would not check it as often if it is checking the flag

i think that you have a misconception about how fast the arduino operates

@jsotola possibly as I'm used to python which is slow. If I was trying to pick up serial signals to tell it to send data back would it still be fast enough to do the monitoring inside loop()

basically, do not use any print statements or wait statements inside the ISR ................ do not use delay() in loop() either ........ refer to BlinkWithoutDelay example sketch that is included  in the Arduino IDE

I think, when you didn't use interrupts you achieved enough debouncing with the duration of your main loop. When using interrupts you might have to debounce the resistor yourself. Bit you have to do this in the loop, just raise a flag in the isr


text:
Does this sound like a good approach to decoding a dumb keypad?
The background:

I bought a "dumb" 8-pin 4x4 keypad for use in a project. (This one: https://www.sparkfun.com/products/14881
It has a wire connected to each row, and a wire connected to each column. When you press a key, it connects a row pin and a column pin. You have to use GPIO outputs to send +5V down one row/column at a time, and then use inputs to look for a HIGH on a corresponding set of pins from the other dimension, which indicates a connection between a specific row/column pair.)
I found a framework, MultitapKeypad, that at first appeared perfect. It is a nice clean C++ object with a simple main method, getKey(), that returns a struct with information about the key the user pressed. It detects long presses and repeat presses, things I plan on using.
However, when I looked into it I found things were not as good on the inside. The getKey method uses a while (no key pressed) loop that loops forever. The author's solution to not locking up the Arduino any time you are waiting for a keypress is to provide a callback function that the library calls from the while loop.
The idea of turning a sketch's control flow completely upside down and having to do all your app's event handling from the callback of a keypad class just seems wrong. Then control flow from the app's main loop has to go through the keypad's callback when I'm waiting for keys, or through some other flow otherwise.
The framework also makes use of delay() in it's debouncing, another no-no for apps that manage multiple things at once.
I was therefore thinking of writing my own keypad handler.
My current project, a power controller for lights, chargers, and a humidity controlled warm air dryer will run all of those things simultaneously. It has a back-lit LCD for a display, and uses a motion sensor and photoresistor to turn lights on when it detects motion in low light.
It puts the LCD to sleep if it doesn't detect motion or any user input from it's various switches for an extended period.
When I integrate a keypad into the project I would also like to add keypresses to the list of things that keeps the display awake. I don't see an easy way to do that with the LCD library I was using.

My proposed design:
I was thinking of wiring the keypad with all of the row pins connected to a 9th pin with diodes, anodes pointed towards the 9th pin. I'd set that 9th pin up in INPUT_PULLUP mode and attach it to an interrupt, set to trigger on FALLING signal (or perhaps CHANGE. See below.) The row pins would all also be configured as INPUT_PULLUP. The column pins would all be set up as outputs, and driven LOW.
When the user pressed a key, it would connect one of the column pins to a row pin. That would pull that row pin's input LOW, and also pull the interrupt pin LOW, triggering the ISR (Interrupt service routine).
In the ISR I would use port registers to switch all the column pins to HIGH, and then toggle one column pin at a time back to LOW, looking for a row pin to also drop LOW. If one and only one column going LOW triggers one and only one row to go LOW, I know only one button is pressed, and know the row/column combo, and hence the key that was pressed. If multiple columns trigger a row, or more than one row drops to LOW, I know more than one key is pressed. (I could use that info to report multi-key presses if I need to, although >2 keys at a time gets messy fast.)
Once I have a key I could add the key code for that key to a simple ring buffer and set a "key ready" flag. (My ring buffer might contain structs with more than just a key code, like up/down events, time stamps, etc.)
The rest of my sketch could then query my keypad for "key ready" and read one or more keys as needed. I'd provide housekeeping functions for clearing the key buffer, a way to detect buffer overflows, etc.
I guess I'd actually want interrupts on both falling and rising state change, so I could detect key up events and track the duration of key presses.
I'd also need to add debouncing of some sort or another. I could use a simple RC filter on each input pin, but I don't have a lot of room left on my project breadboard and that would require 4 capacitors and 8 resistors.
From what I've read the millis() function is a little slow and best avoided in ISR routines. Is there a fast alternative to get the current clock value directly in an ISR? If so I could use software to debounce the keys.
Are there any obvious flaws in my plan? Does using an ISR like this sound reasonable? The Keypad actually doesn't short the row/column pins together. It uses variable resistances between the row/column combinations, I guess so that you can use a voltage divider and an analog input to figure out which key was pressed based on the measured voltage. The docs for the keypad say the resistance for a row-column pair varies from 10 to 625 ohms. I'm assuming that the key resistance is low enough that even with signal diodes in the circuit, the closed switch resistance should be enough to pull my interrupt pin and my row pins to LOW.
I suppose I could also tie all the columns and all the rows together, hook it to a voltage divider, and see if I could decode the key using an analog input. That would let me do all that decoding with a single pin.
Alternatively, are there other keypad frameworks that handle 3x4 and 4x4 keypads and offer things like repeated taps, long taps, and allow you to trigger events on ANY key press (So I could keep my LCD display awake.)

This is a proposed combined hardware/software solution. I haven’t built or written anything yet, so I don’t have any code to post. I’m hoping somebody with more experience than me can me about the relative merits of what I’m proposing.

Where did you read that the millis function is slow? It is very fast. What is wrong with the rest of your sketch? Does the loop function run 10 times of more per second? then you don't need interrupts. You could use a timer that generates an interrupt (maybe 20 times per second or more) and scan the whole keyboard in the interrupt. That makes it also easier to debounce. Perhaps it is possible to use a transistor that detect a press in the keyboard instead of so many diodes. Have you build a ringbuffer before? I think that ringbuffer code is in the arduino libraries, but I'm not sure.

I’m using 2 DHT22 temp/humidity sensors. The library for reading them stalls the event loop for ≈250ms per read, and I read both every 2 seconds, so the event loop is stalled 1/4 of the time, for 1/4 second each time.

Sounds like X-Y problem. You want to read a keypad with quick response to user input, but you have a blocking function, which prevents your code from running, forcing you to rely on interrupts or timers unnecessarily. Internet search for "DHT22 arduino non blocking" shows that there are other solutions that eliminate the block when reading the sensors.

Thanks for that suggestion. I will indeed look at those alternatives. I also want to look at better libraries for my keypad.

I think the magic keywords are "non blocking" and/or "timer". https://www.eevblog.com/forum/beginners/4x4-keypad-arduino-non-blocking/msg1236988/#msg1236988 Here's a forum post that has example code for a keypad function similar to your structure, except that this person sets up Timer1 on the Arduino to fire on a regular basis, calling an ISR that scans the keys. It doesn't require an external interrupt or a pin change interrupt, only a timer interrupt. It scans fast enough for human interfacing (claim of 160uS to scan keypad?)

I made a simple RF remote control using a very similar method with a 4x4 kepyad, with diodes connected together to trigger an interrupt and read a keypress. After any keypress, the interrupt woke the processor (unmodified 8 MHz Promini with Atmega328P), it used keypad.h library to detect the pressed key, sent that out via a short RF burst (433 MHz transmitter) using the library (8 years ago now, drawing a blank on the name) that became the Radiohead library (find it on github), then went back to sleep. Lasts about a month on 2000mAH (or so?) LiPo battery that is secured to the bottom of the board.
As I recall, I had to write the outputs opposite of their normal state before going to sleep mode for the interrupt to work correctly, then restore them before reading the keypad.h value. Then put them back in opposite state before going back into sleep mode.  Works well, but I only transmit one key at a time.  I don't have complete details here, can post them when I get home later.  You can see a picture of the remote at the bottom of this site - sorry about the scrolling, I managed to overwrite my index.html file that had link/tabs to jump to the various areas that my son did up for me.  http://www.crossroadsfencing.com/BobuinoRev17


text:
Can you use an Arduino to control the output current and voltage of a DC/DC converter?
I am using an arduino to create a device that outputs a specific current and voltage. I was wondering if there are any devices out there such as dc/dc buck boost converters that can be controlled by arduino to output desired powers. I am looking for something rated for at least 50 watts  that can carry at least 3 amps of current.
Thank you all in advance!

I've seen I²C controlled digital potentiometers. I know you can set the output voltage of some power supplies with a pot. If you can also control the current, you could control both properties with a pair of digital pots.

What is the desired input voltage?

@RobertoLoGiacco I currently have a power suppy input voltage of 12V.

Yes, and it's actually far simpler than most realize. I've tried digitpots, but they are quite un-linear and only handle 5v, unless you spend $$$. Early on, i had soldered an LDR in parallel to a buck converter's adjustment pot, and fed that PWM. It worked to somewhat adjust the vout, but had a lot of ripple and was not linear. I had gotten an MCU-controlled linear PSU going, that wasn't too hard, but i always wanted a buck. Just recently, i've found an awesome method and built several MCU-controlled SMPSs.  You don't have to have any special parts or de-solder anything!
Basically, you:

use a buck/boost (or dual) with a built-in V-adj potentiometer.
use a lowpass to convert the MCU's PWM output into a 0-vcc signal.
feed smoothed PWM voltage to a unity gain opamp to buffer available current.
create a common ground between MCU and SMPS.
feed the buffered 0-vcc control through a resistor into the pot's wiper, ~200-1k.
the amount of "injected" voltage will be inversely proportional to the SMPS's output voltage.

Since most SMPS's feedback is in the area of 1-2.5v, the 0-3.3/5v output of the MCU works well to provide or take away feedback from the regulator. The best part about this scheme is that output voltage regulation is maintained by the SMPS's hardware, the MCU just sets an offest. In short, you can set it to 10v via the MCU, attach a big load, and the voltage stays at 10v!
I've used this technique on the xl4005 and the xl4015, but i would imagine it would work for just about any common driver package.

This is a voltage regulator, the OP asked for a voltage AND current control circuit

@RobertoLoGiacco If you can control the voltage, you can control the current as well. The simplest would be to use the MCU, which probably suffices for loads like motors and heaters. For LEDs or instrumentation, you probably want hardware control. There's many "current limiting" circuits one could place in-line as well, simplest likely being a current shunt with op-amp amplifier driving an NPN darlington in a series-pass regulator or using the opamp to invert and amplify and supplement the SPMS feedback like described above for voltage. If OP wants, I can sketch something out...

@dandavis Sorry if it´s an old topic, but if you´ve got an MCU with a DAC output, like the ESP32, can the DAC output be connected directly to the resistor that connects to the wiper pin, and don´t use the opamp to buffer current?

@Rodrigo: a few thoughts. The 32 only has 256 DAC levels, so I would much prefer to smooth PWM with a cap and resistor instead of the DAC. The relatively low-impedance opamp buffer's output "pushes" a lot harder than the DAC or a smoothed PWM signal, and that may be required to steer the SMPS, depending on the R values of it's feedback circuit. In short, I imagine a DAC-only setup would give you partial range control over the SMPS output, and if only codes 64-196 work, the result could be a rather crude/jumpy control circuit. That might still be acceptable for some applications though...


text:
How to achieve active 4G LTE communication?
I'm not sure if this is correct place to post this, if not PLEASE redirect me to the proper page, as this matter is quite pressing to me.
My entire day was spent researching different methods of inter-Arduino communication, and for my project, using 4G/LTE/LTE-M is clearly the route I need to take. However, I cannot find an answer to my problem:
I see a lot of information about how to continuously upload information to a IoT service/provider, or to a dashboard website. That's great. Problem is, I need an Arduino with a LTE shield to talk to another Arduino with a LTE shield. Suddenly the internet shuts down and I can find next to nothing about communicating between two Arduino's using LTE shields, much less keeping that connection active.
Of course this could be accomplished by uploading data to a IoT site via Arduino A, and retrieving stored information via Arduino B, but I'm afraid that will induce too much latency into my system. I need this to be as FAST as possible.
The module I have my eye set on currently is this one: https://www.cooking-hacks.com/documentation/tutorials/4g-gps-lte-wcdma-hspa-3g-gprs-shield-arduino-raspberry-pi-waspmote-tutorial/#step10
Is there a way to connect directly to another LTE device? How to I keep that connection always active? I know this question is a little broad, but I don't even know where to look! Internet connectivity is not my strong suit. From what I've gathered, I need to set up one Arduino as a server and the other as client. UDP may be the option I'm looking for, but I'm not totally sure. Every single tutorial/explanation I've seen is connecting directly to a webpage or other online service and NOT another LTE device.
Any help or direction is greatly appreciated, thank you!

You won't find any solution - because it is impossible; 4G LTE is not a peer-to-peer protocol.

What is your original design problem? What are your requirements?

@Milliways Then how do digital phone calls work? What about active connections like facetime?
@ MikaelPatel I just need the most basic active connection between two LTE devices, whatever or however that might be.

@HavocRC Facetime and other peer2peer services use a server. Even you can use a server like Firebase to enable communication between the devices. Connecting between 4G to 4G is not possible at all. You may use Bluetooth/WiFi or RF for local communication.


text:
My ESP8266 web server is only displaying text, even after ensuring content type is text/HTML
So I just got my two ESP8266/ESP-12E WiFi development boards in the mail as I am trying to set up a few home automation devices in my house. I've gotten much further than I thought I would today, considering this is my first foray into working with circuits that involve microprocessors/WiFi, but I've run into a problem that I can't find a solution to myself.  Forgive me if there is another question similar to this, but I could not find it and this seems like the best place to ask.
I am using a tutorial/template program that Rui Santos from Random Nerd Tutorials was kind enough to create ( https://randomnerdtutorials.com/esp8266-web-server/ ), and although we have (as far as I can tell) identical boards, operating systems and Arduino code, I keep getting an HTML page that is text only, with none of the CSS or HTML elements showing.  It should look like this:

However, I am getting a page that looks like this:

His serial monitor is giving this response:

My serial monitor is giving me this response:

I've tried putting client.println("Content-type:text/html"); in a few places to see if it would help display the page, but to no avail.  Any help with getting this little program/website running would be greatly appreciated.
Thanks for your time!

clearly you're adding the content-type incorrectly in the code you haven't shared, because if you added it correctly, it would be sent as a response header, as it is, your code that you haven't shared is putting content-type:...etc in the response body - but as the code you haven't shared is not visible, I could be wrong (but I'm not)

I've tried putting client.println("Content-type:text/html"); how about keeping it where the tutorial has it?

The program didn't display the page correctly as-is, that's why I tried that, I have zero experience with code until now so I figured I'd give it a shot.  What's the best way to show you the code?

Oh. So the original code is broken?

It's possible that there's a compatibility issue between the code and my esp8266 or my OS but nothing I can pinpoint.  There have been a lot of issues in the comments of that article but also lots of success stories, no issues reflect this problem though

Don't use the low-level tools to handle http, use the built-in http tools. They  make creating http responses trivial. No more concatenating headers or worrying about client status; it provides a nice clean function ex:server.send(404, "text/plain", message); and nice subscription method: server.on().
Checkout its usage on one of the Arduino ESP8266's built-in examples:
https://github.com/esp8266/ESPWebServer/blob/master/examples/HelloServer/HelloServer.ino

The use of HTTP here is fairly straight forward so I think printing out your own HTTP headers is OK, you just need to be very specific with the order and send exactly what the browser expects. Without seeing your code, my guess is that you're sending out a blank line to the client somewhere prior to the 'Content-type: text/html' line being sent or that you're not printing an empty blank line somewhere after the Content-type line is being sent. If your browser (the client) doesn't receive the HTTP protocol commands that it expects in the order that it expects, then it will default to displaying EVERYTHING you send it as either plain text or an HTML document. To illustrate exactly what is supposed to be sent to the browser in this example:
HTTP/1.1 200 OK
Content-type:text/html
Connection: close

<HTML>....

Note that there should be a empty line printed out after the Connection: close line and before you send any HTML. There should be nothing else sent to the client prior to the HTTP/1.1 200 OK line being sent and before your HTML code starts. If you don't follow the protocol, your browser will probably default to displaying everything plain text as you're seeing.
Something else I noticed in the example code, there is no space between Content-type: and text/html. This is unusual, but I guess it doesn't break the protocol and Firefox and Chrome handle it ok in my testing. Still, it could cause issues if a browser doesn't handle that properly so you might just try adding a space between the header and it's value.


text:
How can I use an MPU6050 with Arduino to measure linear speed?
I need to measure linear speed of a body which travels 1000 m forward and backward recursively. How can I use an MPU6050 with Arduino Nano to measure the linear speed of a moving object? (the object does not have any rotation). I tried my best, but I was not able to measure linear speed, can I get sample source code?

You can't. Integration of horizontal accelerations will give you a considerable error.

Exactly. Error will add up making your measurement completely useless. On the other hand, I assume 1000m is somewhere in the open. So adding GPS to the accelerometer, and using Kálmán filter to use both sensors will give you acceptable results. Or if your movement is on rails or wheels, using an encoder will be even better.

The problem is small errors and drift. If your acceleration reading is off by 5% for each reading, that error compounds and after just a few readings the error completely swamps the calculated velocity and position readings. You can't sense velocity using an accelerometer, so you have no way to tell if you are moving at 0 kpm or 1000 kpm.


text:
Serial.read() doesnt work in IF statement
I am working with an XBee module, so naturally, I started my void loop with AT command testing.
void loop() {
    digitalWrite(Sleep_Rq,LOW);

A +++ with a guard time of 1 sec before and after it, sets xbee module in command mode.
delay(1000);
xbeeSerial.write("+++");              // Enter Command Mode
delay(1000);

This part of the code, puts the serial data into string variable x in the form of a String.
while(xbeeSerial.available()) {
    x = xbeeSerial.readString();
}

Serial.println() is returning OK onto the serial monitor.
Serial.println(x);

But when I compare x with OK nothing happens, 1 doesn't appear on the serial monitor.
if(x=="OK")
  {
   Serial.println(1);
  }
}

I tried swapping "OK" with 4F4B (ascii equivalent of OK), 20299 (decimal value). I also  tried changing datatype of x from String to word and compared x with 0100111101001011.
I also tried changing the IF condition as,
if(Serial.println(x)=="OK")
    {
     Serial.println(1);
    }

and many more techniques with no luck to be found.

X is probably not "OK" but "OK\n" or "OK\r" or even "OK\r\n".  Read: https://majenko.co.uk/blog/reading-serial-arduino

@Majenko, you should post that as an answer so the OP can accept it and everybody can tell that the question has been answered.

@DuncanC I don't know which of those is the actual fix... Also I'm busy...

Oh, sorry, I didn't mention. The correct one is "OK\r".

Possible duplicate of String compare when using Serial

Your problem is that you are assuming that all you see in the Serial Monitor is all there is. You see "OK", so you expect to compare the text that comes in with "OK".
However it's not. Serial communication (at least, text based serial communication) generally includes some kind of line ending marker. That could be any combination of Carriage Return (\r) and/or Line Feed (\n). Different devices use different combinations.
As it turns out the XBee uses '\r' as the line ending marker.
There are two ways of dealing with it:

Include the line ending in your comparison ("OK\r"), or better,
Incorporate the line ending in the reading.

The second point there involves the use of readStringUntil():
String x = xbeeSerial.readStringUntil('\r');

That is a more reliable way of reading the response since it reads everything up to the line ending, rather than reading until it times out with nothing else to read. You should find your whole program runs smoother with that method.


text:
Need help combining two sketches (HC05 and temperature)
I have a project where I have to combine 4 sensors and get data wireless via Bluetooth (HC05). I just want help with combining just 1 sensor sketch and the Bluetooth sketch. I want the data from the temperature sensor to be displayed on my phone.
Temperature sensor code:
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
}

void loop(void)
{
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  Serial.print(" Requesting temperatures...");
  sensors.requestTemperatures();
  Serial.println("DONE");

  Serial.print("Temperature is: ");
  Serial.print(sensors.getTempCByIndex(0));
  delay(1000);
}

Bluetooth code:

#include <SoftwareSerial.h>
SoftwareSerial BT(11, 10);
int ledPin = 8;
int state = 0;

void setup()

{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
BT.begin(9600);
}

void loop() {
  if(BT.available() > 0){
  state = BT.read();

  }
    if (state == '0'){
      digitalWrite(ledPin, LOW);
      BT.println("LED: OFF");
      state = 0;
    }
    else if (state == '1'){
      digitalWrite(ledPin, HIGH);
      BT.println("LED: ON");;
      state = 0;

    }
}

Instead of writing it all out, I give some tips:

First combine the content of both setup functions. You can remove duplicate lines (e.g. Serial.begin(9600); is needed only once. Keep the order in a logical way.
Than combine the content of both loop functions. However, the delay could cause a problem. Replace this by keeping a variable with the current time, and check when it's at least a second ago you checked the temperature sensor, if so, measure the sensor (and update the variable to the current time).

So you get something like:
unsigned long lastSensorMeasurement;

void setup()
{
   // Combination of both setup functions

   lastSensorMeasurement = millis();
}

void loop()
{
   // Process sensor
   if (lastSensorMeasurement + 1000 >= millis())
   {
      // Code for sensor as in loop
   }

   // Process Bluetooth
   // Code for bluetooth as in loop
}

now() only has a resolution of 1 second. Usually you use millis() for timing, which gives 1/1000 of a second resolution.

@DuncanC Thanks ... of course I meant that; I updated my answer, thanks for the notification.


text:
Too little current to trigger a relay?
I try to use this relay with a Arduino Mega. I connected with jumper cables

5V pin to DC+,
GND to DC- and
Digital Pin 13 (because its a lucky number) to IN.

The power LED from the relay is lighting green.
I run this code, which should trigger the relay every 3s for 3s:
int pinOut = 13;

void setup() {
  pinMode(10, OUTPUT);
}

void loop() {
  digitalWrite(pinOut, LOW);
  delay(3000);

  digitalWrite(pinOut, HIGH);
  delay(3000);
}

When initializing the sketch, the red light (from the relay) is flashing and the relay is clicking. But afterwards nothing happens.
With my multimeter I check the currents:

5V to GND = ~5V
Pin13 to GND, when not connected to relay = ~4.7V
Pin13 to GND, when connected to relay = ~1.2V

The relay needs 5V and 5mA triggering current. I don't think the Arduino is not suited, since they promote the relay Arduino.
Any ideas? Do I need some kind of resistor? Or is the USB port from the laptop not sufficient? I used two different Arduino Mega's with two different relays. By the way i don't have a big background in electric.

but what do you want with not so lucky 10?

You are using pin 13, but you set pin 10 as an OUTPUT.
pinMode(10, OUTPUT);
Try changing that to
pinMode(pinOut, OUTPUT);
PS by not setting pin 13 to OUTPUT, digitalWrite(pinOut, HIGH); enables the internal pull-up, instead of "connecting" it to 5V. The internal resistors are around 35kOhm. So pulling a bit of current through them will result in a lower voltage at the pin.

OMG it is working now. I was trying for hours and in the end it was just a wrong number. Thanks a lot.

We've all been there. (-;

There but for the grace of god go I. The hardest bugs to fix are ones where you see what you expect to see, not what's there. Good catch. (Voted)


text:
Setting up two arduinos connected to separate serial ports with wires in-between
I intend to have both an Arduino Nano and an Uno connected to a PC via the on-board USB ports, but have them inter-connected with wires from one's GPIO pins to the other's (one reads the status of the other's pins). I've read that having two Arduinos communicate with each other requires them to share a common ground, so am not sure if this will work at all (the common power source in the PC may serve as the common ground, I'm not sure).
As some background, I would like the Nano to serve as an EEPROM programmer and have the Uno connected as a logic analyser to help debug the EEPROM programmer, both using serial to communicate with the PC in real-time.
How should I set up the Arduinos and power supply to make this possible in a safe way?

https://majenko.co.uk/blog/importance-sharing-grounds

can you not run a ground wire next to the tx or rx wires? it doesn't have to come from the power connections...

what is your question?


text:
Digispark ATtiny 85 - not recognised as HID device
I am trying to create auto-username-writer with Digispark ATtiny 85. I have a pretty simple sketch:
#include <DigiKeyboard.h>
void setup() {
}
void loop() {
    DigiKeyboard.sendKeyStroke(0);
    DigiKeyboard.delay(100);
    DigiKeyboard.sendKeyStroke(76, MOD_ALT_RIGHT | MOD_CONTROL_LEFT); //ctrl+alt+del
    DigiKeyboard.delay(2000);
    DigiKeyboard.print("username");
    DigiKeyboard.sendKeyStroke(0x2B); //tab

    for (;;) {}
}

When I upload the code via Arduino IDE into the device (Board: Digispark (Default - 16.5MHz), it finishes successfully, it is recognised as a HID device and immediately performs all the tasks. But when I disconnect it and connect it again (to my PC or any other PC) it is recognised as Digispark Bootloader and does not do anything.
I have tried it in Arduino IDE 1.8.8 and in Arduino IDE 1.6.5 and I have no idea why it is only recognised right after upload. I have two ATtinys and both do the same behaviour.
Can someone help me, please?
EDIT:
I tried adding digitalWrite(1, HIGH); to detect, whether the sketch even runs and it turned out it does not even run (except after the upload)...

are you waiting 5 seconds for the sketch to start executing?

Well, I have tried adding something like a 4-second delay at the start and I even let the ATTiny be in USB for some time. Neither helped...

the title of your post indicates that you have not identified the problem correctly, so it is difficult to find a solution on the internet  ..... not recognised as HID device is not the problem ....... the problem is that the loaded program does not start after the digispark is reset  .... the digispark enters program loader mode and does not continue to the loaded program after a timeout

You are probably right. At time of writing I did not know the sketch is not executing. I tried googling the problem in regard what you have written, but was also unsuccessful - did not find anything I can use.

After five seconds, which is when the bootloader should switch to running your code, how does it show up in the list of usb devices (lsusb in Linux, Device Manager in Windows, etc.)
The original Digispark was a bit temperamental when plugged into USB 3 ports. If you are plugging it into one, try using a usb2 hub and plugging it into the hub instead.
Also, did you get this from Digistump, or is it a knock-off?

I have tried several USB ports (2 and 3) and neither worked even after extended period of time.  Whole time it is shown in device manager as Digispark bootloader. Unfortunately I bought it in a local Czech e-shop, so I have no idea whether they are selling clone or original. Is there a way to detect whether it is original or clone?

I just run your sketch on a digispark, and it behaved as expected; at this point the easiest thing to do is to just get another little digispark and see if that one works. It's open-source hardware, so chances are that unless you ordered it from digistump directly, it's a knockoff.

I hope I'm not too late here, but I believe you may need to update the bootloader.  Could you try the instructions here? https://www.iot-experiments.com/micronucleus-bootloader-upgrade/  I happened to be reading through this guide: https://hackernoon.com/low-cost-usb-rubber-ducky-pen-test-tool-for-3-using-digispark-and-duck2spark-5d59afc1910 and the troubleshooting section there sounds like the issue you're having.

Hi, thank you for your answer. I tried upgrading the firmware, but unfortunately without any success, here is micronucleus.exe output: https://pastebin.com/2SsexNQ4 .

Same here,
I am new user so not saying this is the correct way.
I now includes "digiKeyboard.update();" and "digiKeyboard.delay(1000);". both at top ,both to trigger usb signal many many times to the host.
the "digiKeyboard.sendKeyStroke(0);" does not work every time.


text:
Power external daughter board from Arduino only powered by USB?
Been searching for an answer, but I see lots of talk about it, but not clear answers. Can somebody clarify this? If I power the Arduino only via USB, can I put a small daughter board? and power it from the Power connector(5V)
Update:
Thanks for the answers I'm using a Genuino UNO and it does power the daughter board my meter was kaputt, got a good one and it is fine even hooked a breadboard circuit to the 5V and GND and it works!!!

Probably the reason there is a lot of talk, but no clear answers, is that everyone has a different idea of what a "small" daughter board is; there is a limited power margin, and every LED, sensor or other add-on uses some power. The only true answer is "it depends on your specific situation".

Yes. USB is limited to 500mA, the Arduino like an Uno has a 500mA fuse to protect the USB source.
The Arduino itself can use 25-50mA of that, or more depending on what you have connected to the IO pins.

note that USB3 officially provides almost an amp, while most computers and virtually all mains-usb "chargers" provide more than 500ma. Both apple and samsung "wall worts" for example provide 2 amps.


text:
Arduino security
My question is how secure can I make an Arduino? The project I am working on would put the Arduino out in the public (school campus inside a trash can to sense how much trash is in it) and I want to make sure random people can't access it and mess/change the code. Any suggestions would be helpful.
It will also be connected to the network and be sending data to a database.

Define "secure". Put in it a safe and it's "secure".

I'm voting to close this question as off-topic because it is about physical security, not Arduino.

I think the OP was asking about software security. That seems like a valid topic.

Software-wise, and Arduino is completely insecure. There is no login, there are no passwords, nothing. You just need a computer and access to the USB port. You will need to use physical security to protect it.

@DuncanC yes I want to know about password protection and other software protections and can i add them

No. If somebody has access to the USB port, there is no security.

@Majenko the OP clarified to indicate that they are asking about software security, so this seems like a valid question.

If the sketch (web-server part) does support data update the access can be restricted to specific MAC addresses. If the sketch uses Serial for configuration, etc, a password/encryption might be needed. In other cases, if the sketch only sends data to a server (database) there is not much to secure other than environment (tampering) of the device.

If I understand your question, then you want ensure, that nobody is able read and change your code to see, what are you doing and to send you fake data from that Arduino.
What are problems here:

It can be stolen (eventually with the entire trash bin) - means no fake data and no data
It can be vandalised/destroyed in matter of minutes (max) - again no (real/fake) data
The arduino can be reprogrammed by normal way (via bootloader) and send fake data - you can prevent that by changing the bootloader
Arduino can be read and reprogrammed by ISP and send fake data - you can lock it (by setting SPIEN) to prevent both reading its memory and to reprogramming it this way
the lock can be cleaned and chip erased and reprogrammed (but not read) by Chip Erase command from High Voltage programming. You can make it more difficult, if needed pins are attached to some devices or ground/power.
the chip can be desoldered, reprogrammed and soldered back to avoid problems with connected devices.
also the whole Arduino can be swapped with already tampered Arduino
another Arduino can be atached to the net to inject fake data (and maybe prevent the original from normal transfers by interference)
(so it have problems with physical security)

To mess with your data (send fake) such program need to be able send data in (somehow) correct format over the net. Without source code or at least the code in Arduino the format of the data could still be sniffed from transmissions and deciphered (but it is difficult task to do) and you can employ some crytography to make it even harder (but it would eat a lot of memory and computing power from your code).

Well, in practical life your problem is stolen/vandalised arduino and simple attacks, which can be blocked by locking the Arduino fuses and bootloader (but you would have hard time put update there after locking it) and using some cryptography.

thank you for the response it was very helpful

Software security features are not available in Arduino. However if you want to prevent people from flashing a new code to some extent, you can desolder the USB pins or use a version of Arduino like ProMini, that requires external USB connector for coding.

yes, just to some extent.


text:
Not able to convert String to Integer when receiving data from pubnub?
I did managed to upload mpu9250 sensor data on PubNub and nodeMcu but not able to use the received data to control servo
Look at the Port reading and see that servo angle is still showing '0'

Code:-
IMU.readSensor();
char buf[500] = {};
int imu = IMU.getAccelX_mss() * 10;

sprintf(buf, "\"%d\"", imu);

Serial.print(buf);

PubNonSubClient *pclient = PubNub.publish(pubchannel, buf);
if (!pclient) return;
PublishCracker cheez;
cheez.read_and_parse(pclient);

/** You're mostly interested in `outcome()`, and,
    if it's "failed", then `description()`.
*/

Serial.print("Outcome: "); Serial.print(cheez.outcome());
Serial.print(' '); Serial.println(cheez.to_str(cheez.outcome()));
Serial.print("description: "); Serial.println(cheez.description());
Serial.print("timestamp: "); Serial.println(cheez.timestamp());
Serial.print("state: "); Serial.print(cheez.state());
Serial.print(' '); Serial.println(cheez.to_str(cheez.state()));
Serial.print("IMU Reading: "); Serial.println(IMU.getAccelX_mss());

pclient->stop();

/* Wait for news. */
PubSubClient *sclient = PubNub.subscribe(subchannel);
if (!sclient) return; // error
String msg;
SubscribeCracker ritz(sclient);
while (!ritz.finished()) {
    ritz.get(msg);
    if (msg.length() > 0) {
        Serial.print("Received: "); Serial.println(msg);
        pos = msg.toInt();
        Serial.print("value of servo angle: "); Serial.println(pos);
        myservo.write(pos);
    }

}
sclient->stop();

delay(1000);

How do I convert a string to integer so that it can be used in servo?

Hint: Might need to remove the extra characters ("..") before converting from a string to an integer.

oh yes, let me try it

This is the code which worked for me:-
        msg.remove(0,1); msg.remove(msg.length());
        pos = msg.toInt();
        Serial.print("value of servo angle: "); Serial.println(pos);
        myservo.write(pos);

I had to remove this character (" ") by using msg.remove(0,1) & msg.remove(msg.length()) that removes starting and ending string.

cleaner: msg.trim(); Serial.println("value of servo angle:" + String(msg.toInt());

nice, much better

but msg.trim() didn't work

it's a void mutative method in ardunio, not a transformer like in other languages.


text:
How to read analog pins from a second Arduino
I've run out of analog pins on Arduino Uno and don't have time to order new parts. I've heard you can connect two Arduinos and I have access to another UNO. If I did that, could I read the analog pins of the second Uno on the first one?
I'm planning to control 7 servos with separate potentiometers.

Why not buy an I2C or SPI ADC like the MCP3208? Needs the digital SPI on your Arduino Uno but gives you more 8 analog inputs. You can also buy two MCP3208, put them on the same SPI bus to give you 16 new analog inputs. Inter-Arduino communication is more complicated and costs more money. For I2C you have MCP3428.

Please tell us what you have connected to the analog pins. Perhaps we can find a way to change that. Do you need 7 potentiometers? It is for example possible to use a single analog input for 7 potentionmeters without extra hardware. That requires 14 digital pins to be able to power each potentiometer seperately.

I have connected several potentiometers and servos. I need to control the servo angle in real time, it's a lazer puzzle with mirrors redirecting the beam from one to another with real time inputs from potentiometers. There are 7 servos, each with their separate controls.

Yes that is possible, you can even use as many Arduino's as you want and send the information to one 'master' Arduino to process the data.
What you need is a way to communicate between them. Depending on distance, speed and reliability, you can chose for Serial, I2C, SPI or more 'exotic' solutions like CAN(bus), RS485 or even wireless methods (with nRF modules).
Some have a simple protocol, for others you might have to make it yourself.
Also think of the processing, you want to do the processing on the main device, or to process as much as possible on the 'slave' Arduinos and send it to the main device.
(Btw, I talk about Master/Slaves), these are not official terms, but meant as example. For example, with CAN, you can send message from any Arduino to any other. With Serial, you can send from 1 Arduino to 1 other.
If you have 2 Arduino's, probably Serial is the easiest.

Serial is best. Other protocols like I2C are bit complex to send and receive, requires understanding of I2C protocols, etc


text:
Door control with Arduino and limit switches
I want to make a door with two limit switches and three buttons: one for stop and the other two for open and close. I run into a problem with the code with the start buttons and the limit switches. I can't make the code because I'm a beginner. Please can somebody help me with some code or something like that?
I'll appreciate it if you help me, because it's for my school project:)

Try something simpler first yourself: one button, try to read it; than a switch and try to read it; from there you make requirements for what you need. And if you run into a more specific problem you can ask again here; you also need a motor to open/close the door I assume?

Please provide a code that you have done, which is not working.

How does "help me with some code..." help you learn anything? There are many tutorials and example sketches to try out and build an understanding about how the Arduino can be used. There are no free lunches in the real-world :)

You will need to write code to

Control a motor. Likely a DC motor with two way control. This can be done with four MOSFETs and several diodes or much better, one H bridge IC. Your code will need to determine which one of two lines going to the dc motor is getting connected to the positive rail, and which one to the negative/ground, or both disconnected, using the three buttons you described.
You will need to write code that monitors the limit switches. I would suggest you use interrupts for these. One pin goes to ground, the other goes to the Arduino interrupt pin. You can use attachInterrupt() function to write functions that execute right away. Make sure you read up on which pins on your Arduino will support interrupts.
You will need to stop the motor movement either directly or by throwing a switch using the interrupt (or whatever detection method you use for the limit switch).

*one special consideration is that any variables that you use inside of interrupt functions should be marked as volatile, so int myVar; becomes volatile int myVar;
*also don't use Serial.print or millis() inside of your interrupt functions if can avoid it.

From here Google 'Arduino switch' and work on an implementation of limit switches separately. If you want to, Google 'Arduino Interrupts' and improve your implementation to use interrupts. Next, Google 'DC motor bidirectional control Arduino'. Work on it standalone. Once both work separately, combine into a single project.
Let me know as you go through these if you have specific questions, and I would be happy to help you learn how to build it using the components you have.


text:
FastLED Rainbow Wheel Fade on an 8 Pin RGB Matrix
So, I have an RGB matrix (using PL9823 LEDs) that's 32 x 8 that I'm trying to run a circular spinning rainbow pattern across in a continuous loop. Now, there's lots of code online for different ways to do this with a traditional daisy chained matrix, but I have mine set up to where each of the 8 rows of LEDs goes to a different pin on my Teensy 3.2 controller (pins 4-11) and I have no idea how to get this (or any) rainbow effect working on it. I'm using the FastLED library and this is how I have the program set up to address individual pins as the different rows of LEDs:
#include "FastLED.h"
#define LED_TYPE PL9823
#define NUM_STRIPS 8
#define NUM_LEDS_PER_STRIP 64
#define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS

#define COLOR_ORDER GRB

uint8_t hue = 0;

CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
CRGB row_1[64];
CRGB row_2[64];
CRGB row_3[64];
CRGB row_4[64];
CRGB row_5[64];
CRGB row_6[64];
CRGB row_7[64];
CRGB row_8[64];

void setup() {
  FastLED.addLeds<PL9823, 4>(row_1, 0, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<PL9823, 5>(row_2, 0, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<PL9823, 6>(row_3, 0, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<PL9823, 7>(row_4, 0, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<PL9823, 8>(row_5, 0, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<PL9823, 9>(row_6, 0, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<PL9823, 10>(row_7, 0, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<PL9823, 11>(row_8, 0, NUM_LEDS_PER_STRIP);

}

Does anyone know how I can make this setup run a spinning wheel of fading color values in the form of a spinning rainbow? I'm hoping to use suggestions as a place to start to build other patterns with and without rainbows as well and I'm a bit of a noob, so an explanation is appreciated.

why don't you start with basics and learn how to display a simple monochrome circle

why are you using a separate data pin for each row?

The display is set up as such that the rows cannot be daisy chained and all the inputs are on on side

Also, I am able to address individual LEDs on the matrix, set their color, and move them more or less by building frames one LED at a time.

that kind of setup is unlikely to have easy, built-in support with existing libraries, since all the animation call would be broken up 8 ways. can't you wrap the data lines around?

You're able to light any given pixel in any given colour, so am I correct in saying that what you want now is an algorithm to give you the rainbow effect? Could you confirm exactly what effect you are looking for? A star with different coloured lines coming out from the centre?


text:
Can't flash ESP 32 Wroom

I have a new ESP32 Wroom attached to my USB and it shows up in the settings on my mac:

I do have another ESP thing from sparkfun which I can access via  /dev/cu.usbserial-DN02N1D8. This device I can flash without problems or read its mac address using esptool.py.
Connecting........_____....._____....._____....._____....._____....._____....._____

So I wonder how I can flash the ESP32.
Update: Added a picture of my board.

does the ESP32 contain a bootloader? ...... does it show up as a serial port?

I don't know for sure, but I would assume that it has a boot loader. It does not show up as an additional /dev/cu.XYZ entry, like the ESP-Thing does (/dev/cu.usbserial-DN02N1D8)

@jsotola, why do you ask if it has a bootloader? as far as I know the Espressif chips have only serial upload so without a bootloader from factory they were useless

How have you attached the device? The esp wroom 32 is not soldered onto any kind of breakout board, so have you soldered wires to rx/tx?! Do you actually have a reset button? If not, there is no chance to flash it. When trying to flash without the esp being in program mode I would expect exactly what you are seeing

you might have to hold some pins hi/lo to get it to flash. on some of my esp32 modules, that's holding down the flash button, on some it grounding a certain pin (0 i think) between starting the ide upload and actually uploading it, which is a bit of a balancing act. I recommend that once you get it flashed, use an OTA method to avoid the physical challenge.

I did fix the problem now.
My mac has USB-C and I was using a single USB-C to USB Dongle. And the serial port never showed up on my mac:
crw-rw-rw-  1 root  wheel   18,   5 Mar  8 10:53 /dev/cu.Bluetooth-Incoming-Port
crw-rw-rw-  1 root  wheel   18,   7 Mar  8 10:53 /dev/cu.Heinz-WirelessiAP
crw-rw-rw-  1 root  wheel   18,   3 Mar  8 10:53 /dev/cu.MALS
crw-rw-rw-  1 root  wheel   18,   1 Mar  8 11:02 /dev/cu.SOC

As soon as I used the Satechi USB Dock the Silicon Labs USB to UART port showed up in the list:
[...]
crw-rw-rw-  1 root  wheel   18,  13 Mar  8 11:04 /dev/cu.SLAB_USBtoUART

I can now communicate with the ESP32:
esptool.py --port /dev/cu.SLAB_USBtoUART read_mac

esptool.py v2.6
Serial port /dev/cu.SLAB_USBtoUART
Connecting........___
Detecting chip type... ESP32
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: XXXXXXXXX
Uploading stub...
Running stub...
Stub running...
MAC: XXXXXXX
Hard resetting via RTS pin...

Please note that if you'll need the Drivers for the USB to Serial Chip from Silabs.
If you do not see the device showing up you'll need to load the kernel extension:
sudo kextload /Library/Extensions/SiLabsUSBDriver.kext/

After this you might to confirm the extension in the Privacy section of the mac settings. See this forum post for reference.

Flash ESP WROOM 32
kindly refer the link :
   https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html#

Your link seems to have a typo in it.

@Besi the link is corrected