New answers tagged

0

Majenko has it right, your String array should be allocated in Setup(). Notice that I passed back the success/failure of your initial EEPROM test as the return value. void setup() { Serial.begin(115200); Eeprom::configuration::initialize(); const int keys = 2; String ssid_password[keys]; if (Eeprom::configuration::read(ssid_password)) { ...


0

While I do believe you could use GPIO2, TX, and RX for your connections, I don't think the clock is explicitly exposed on the ESP-01. That means your code would have to "emulate" a clock via GPIO2 (most likely) with that pin going to your shift register's clock pin. That said, it's really hackish and I'd recommend other ESP dev board that has a pin for the ...


2

You can't return locally defined arrays like that. The array only exists in the function, and all you do is return a pointer to where that array was. As the array has gone when you leave the function your pointer just points to garbage. Instead you should pass an array to the function that the function then populates.


0

It turns out i'm just really stupid. I spent something like 7 hours to make things work but i just selected the wrong card during the whole time. Sorry for bothering you guys :-/


0

When a program crashes, you can debug the crash based on the Fatal exception number. Exception (9) Unaligned read/write operation addresses 1. Unaligned read/write Cache addresses 2. Wild pointers This leads than as Juraj points out to a WD reset: rst:4 Hardware WDT reset To get the exact part of the code paste the >>>stack>&...


2

That depends on if you're using a NodeMCU or a "naked" ESP8266. The NodeMCU has a fixed voltage divider with 220K/100K resistors to ground, contributing about 10 µA to quiescent current (plus the much smaller current caused by the ADC input impedance). If you're using a NodeMCU you also have to worry about the USB-to-Serial chip and the on-board ...


1

Thanks to Delta_G for pointing me in the right direction. The trick was to not get stuck in the loop() function, ie. no while loops. The problem was that after you run client = server.available();, the client needs some time before client.available() returns true, which is what the while loop is for, however, for some reason, the client would lose its ...


1

This is an old post but probably somebody can use this info: void mqtt_callback(char* topic, byte* payload, unsigned int length) { String topicStr = topic; String recv_payload = String(( char *) payload); Serial.println( "mqtt_callback - message arrived - topic [" + topicStr + "] payload [" + recv_payload + "]" ); }


1

To write code that will not cause memory leak, you need to understand of where and what caused the memory leak first. The memory leak in this particular case is caused by the line serial_data_read.concat(character); When you instantiate a String object with String serial_data_read = "", Arduino String class create a memory allocation using dynamic memory ...


2

Your circuit drawing seems very wrong, but it is not helpful since, as you say, it doesn't represent the real circuit. Please, add a proper diagram of the actual circuit. As for your reliability problem, I did not dig into the logic of the code you posted, but I suspect it may be caused by the lack of debouncing. You could add you own debouncing code but, ...


1

The short answer is, don't use the String class at all. You need to read up on using C strings (which are simply null-terminated arrays of characters. There are C library functions for manipulating C strings. You'll want to avoid printf, scanf, and related functions, as the library that supports those is quite large The basic idea is to use statically ...


0

The D1 R2 uses the same power supply arrangement as the Arduino Uno (albeit with a better switching regulator for the 5V instead of the Arduino's basic linear regulator). So it should be safe to use both the USB and the barrel jack at the same time. The NodeMCU doesn't include a 5V regulator and doesn't have the power switching circuitry of the Uno / D1 R2,...


0

After looking into it and seeing all the previous answers, I noticed the Vin pin can be used as an output but only up to the input from the barrel connector. When using a 9V input to the barrel jack, the voltage difference between the ground pin and Vin pin was just under 9V. Similarly, when measuring the voltage difference when using a 12V supply, the ...


0

It seems I got it working! Thanks a lot for your help, I owe you a few beers. For anyone following and interested here is my code: LSM303DLHC including accelerometer to correct for position Vector calculation to be implemented */ #include <Wire.h> #include <Math.h> const int LSM303_ADDR = 0x19; const int LSM303_ADDR_MAG = 0x1E; //control ...


1

You cannot. You are misunderstanding, what that pin is. Vin means Voltage In. It's a voltage input, connected to a voltage regulator, which will regulate the provided voltage at that pin down to 3.3V for the Wemos to work with. It is not an output. The regulator cannot convert the 3.3V from the Wemos to 12V. That is not, what it is build for. To get 12V you ...


1

Ok, I have finally found the issue, and I am feeling very, very stupid. I needed to calibrate the magnetometer with the figure-8 movement I put a gigantic solid-metal 18650 Li-ion cell right next to the magnetometer chip... EDIT: after replacing the 18650 with a polymer battery that is far away from the chip, things got a little better but both sensors in ...


0

Found it...Magneto data is coming out XZY not XYZ...when I changed this it works! Sorry, RTFMA would have given me the answer straight away.


1

I don't know if this is your problem, but I'll leave it here because it is certainly a potential bug. This code in loop: while(!client.available()){ delay(1); } can cause a deadlock if you have a client that drops or doesn't talk. Turn that around and let the loop keep running. boolean haveClient = false; void loop() { client = server....


0

That is not a good idea. Isolating the relay from the IO pin is not just about the current limit of an IO pin, it's also about preventing back-EMF spikes from the relay coil(s) from damaging the delicate internals of the chip. Instead you must at least use a transistor and a back-EMF protecting diode. However - if you did want to theoretically have two ...


0

#include <WiFiEsp.h> #include <WiFiEspClient.h> #include <SoftwareSerial.h> ... SoftwareSerial wifiSerial(WIFI_RX, WIFI_TX); WiFiEspClient WIFI_CLIENT; ... void setup() { wifiSerial.begin(9600); // or 115200 WiFi.init(&wifiSerial); if (WiFi.status() == WL_NO_SHIELD) { printLog("WiFi shield not present"); // don't ...


3

You can't. The password does not exist. In short: The password is used to create a key The key is used to encrypt the connection If both ends agree on the encryption then it's "connected" and packets can travel back and forth. There is no password for you to print, only the fact that encryption didn't agree. It actuality it's more complex than that, but ...


0

I can think of two ways of doing this. One is to use the H channel of the HSV colour space (as I show in the answer to this question. This would give you a smooth transition between two colours through the pre-defined spectrum of the hue range. The second is to simply specify two colours and then mix them at different percentages depending on how far along ...


0

Apart from ensuring you're wiring TX -> RX and connecting all grounds, you can use SerialTransfer.h to automatically packetize and parse your data for inter-Arduino communication without the headace. The library is installable through the Arduino IDE and includes many examples. Here are the library's features: This library: can be downloaded via ...


1

It's hard to know what is wrong with your code... because you are not showing it in the question! Here is a basic test I tried on my Uno: #include <time.h> const uint64_t ms = 1588312648603; void setup() { time_t t = ms/1000 - UNIX_OFFSET; Serial.begin(9600); Serial.println(ctime(&t)); } void loop(){} It's output is: Fri May 01 05:...


0

how do I display the time from the DS3231 clock module on the FC-16 led matrix modules? You can use the DateTime::toString() method to convert the current time to a string in the format of your choice, then P.print() to display that string on the LED matrix: void loop() { DateTime now = rtc.now(); char buffer[] = "hh:mm"; // hours and minutes ...


1

Here is the step-by-step on upgrade the ESP-01 AT Command firmware (for running on macOS). Wiring For flashing the ESP-01 firmware, you need to have a USB-TTl adaptor as a programmer. +---------------------+---------+ | | RxD Vcc | | Top View | IO2 RST | | | IO0 CPD | | | GND TxD | +---...


0

You use esptool.py available from github. It's exactly the same usage regardless of which operating system you are using (apart from the serial port device name of course), so instructions for Linux (for example) are the same as instructions for Mac OS X.


0

This will be the "server unreachable after a while" problem, which is solved solved by sending gratuitous ARP requests. In the esp8266 Arduino core 2.7 they added functions for this. The main function is experimental::ESP8266WiFiGratuitous::stationKeepAliveSetIntervalMs();. Include <#include "ESP8266WiFiGratuitous.h> Notes: You don't know if your ...


3

You already received good answer about some general ideas for replacing String objects with C strings. Here I will try to add some more tricks more specifically targeted to your actual situation. I can see two places in your program where the use of String shines by its convenience, and replacing it with C strings will require some effort. The first is the ...


1

I would use something like below. The optical isolator (PC817 or similar) protects your ESP. Use a 1.0-1.5K resistor from the incoming SCART switch signal (SCART pin 8) to the anode of the Opto isolator (pin 1 in case of the PC817). This will limit the current through the PC817 internal LED to about 10mA with a 12V signal but the PC817 can survive up to ...


2

So here is code to get you started: myMessageArray [256] = {'\0'}; // Define global array large enough and zero terminate the + method is replaced by strcpy (myMessageArray, "Text to Add"); // Initializes the myMessageArray starts at index 0 strcat (myMessageArray, "More text to Add"); // Appends to the myMessageArray starts at current index converting ...


1

You asked: "After I replace the String objects with char arrays, how can I use the indexOf() method and + operator on the char arrays?" Short answer: You can't. If you want to use C strings (aka arrays of char), you'll have to use C string functions. The String methods operate on String objects. The common wisdom is to avoid the String class entirely since ...


0

With very few exceptions, electronic devices only draw as much current as they need, limited by their resistance. The current rating on a power supply is the MAX current it can provide before the voltage drops. Having a higher current power supply may waste energy, but won't hurt anything. According to Ohms law, V = IR Where V = Voltage I = current, in ...


Top 50 recent answers are included