I am developing a project using Arduino Uno with DTH Sensor AM2302 and Nextion 4024T032 for display. But after running the program I can't seem to find whats wrong with code. After following steps and process, I come to face an error like this, the Serial Monitor prompts the message " ⸮⸮⸮⸮⸮⸮bkcmd=1⸮⸮⸮page 0⸮⸮⸮ ". I don't know what it means or even what caused the error but due to this the adruino can't communicate with the nextion display.
I know it may seem a simple problem and I guess I just missed a crucial part for setting both of the device. But I really don't know where to start looking now. Wish you could all give me some advice or insights. Thanks.
Regarding on my code I noticed that the error is the result of nexInit() function in the void setup() . When I remove it the error disappears but leaving the arduino and nextion no communication whatsoever.
#include "Nextion.h"
#include "DHT.h"
NexText stat_text = NexText(0,1,"t0");
void setup(void) {
Serial.begin(9600);
nexInit();
}
void loop(void){
stat_text.setText ("Server Condition: Normal");
}
I expect the output would be visible in the display which correspond to the object name of GUI in the nextion display.
I have attached the Serial Monitor Error Output. Serial Monitor Error
If you are sure about your arduino code and you are using new library for nextion, you should delete new library and install old library. new library for nextion has problems.
Related
I have an Arduino-controlled robot with a gyroscope, and I'm trying to send data from it over to a Python program run on a Raspberry Pi. However, there's a 1-2 second delay between me moving the robot, and info being printed out the python program. I've tried restarting my computer, as well as replugging the wires. Is there anything I'm doing in my code that is causing this or is it a hardware thing?
The robot is connected to a Raspberry Pi, with which I have a headless setup. The python program is being run on the Pi but can be viewed on my desktop over SSH. The program has no delay when I connect the robot to my desktop and run the python program on it as well.
Arduino Program:
#include <robot's file>
Gyro gyro; //Object using an imported class
void setup() {
Serial.begin(115200);
while (!Serial) {}
}
void loop() {
gyro.read(); //Reads the robot's yaw and puts it into variable "z"
Serial.println(gyro.z);
}
Python Program:
import serial
from serial.serialutil import SerialException
ser = serial.Serial("/dev/ttyACM0", 115200)
try:
ser.open()
except SerialException:
print("Port already opened")
while True: print(ser.readline())
looks to me that everything is good in your code.
Most of the delay is related to your PC computing time.
If you want to speed up the process I would suggest to interface an Oled display (or an LCD) to display directly your data: using your PC is good for the initial testing, but if you need immediate response it is better to manage the data interfacing directly.
This link may support you: https://www.waveshare.com/wiki/1.3inch_OLED_HAT All the best
After some testing, I think I've figured it out.
Printing to terminal takes a long time, which made the Arduino program faster than the Python program, creating a buildup of data, causing the delay. I've fixed the problem by only printing out data every 10 iterations. The problem would also be fixed if I stored the data into a variable, and did not call the print() function.
Is there any way to detect the code version or any info like last updated or size of code or size of binary code?
Here is example:
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
// turn the LED on (HIGH is the voltage level)
delay(1000);
// wait for a second
digitalWrite(LED_BUILTIN, LOW);
// turn the LED off by making the voltage LOW
delay(1000);
// wait for a second
}
If I upload code to Arduino board, can I detect any info inside Arduino regarding the size of the code or the last modified time or upload time etc?
Thanks.
Compilation date is stored in the __DATE__ macro, the current system time at compilation is stored in the __TIME__ macro. Also useful may be the __FILE__ macro, which stores the filename. Reference (and other relevant macros): http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_preprocessor.Pre-defined_macros.html
There is some interesting discussion about something along these lines here:
https://github.com/arduino/Arduino/issues/5618
In that thread they're discussing ways to store the Git hash of the code at the time of the compilation/upload. If you're using Git version control that information would probably be more useful than last modified time or code size for determining which version is running on your microcontroller and being able to easily retrieve that version. I'm not sure how crazy I am about automatically doing a commit on every upload by you could always squash them later once testing is finalized. If you don't use Git, the same techniques could be adapted to adding any other version information you like and even doing automatic backups of the code at that version.
As explained by facchinm in that thread, recent versions of the Arduino IDE provide hooks throughout the build process that you can use to add additional actions. See:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#pre-and-post-build-hooks-since-ide-165
The original proposal is to store the version information in EEPROM. I believe the most common way to do this is via an .eep file. A problem with this idea is that the popular Optiboot bootloader used by the Arduino Uno as well as popular 3rd party hardware packages does not support writing to EEPROM during uploading (in order to fit the bootloader in a 0.5 kB boot section). You would also need to avoid conflicts caused by use of the same EEPROM addresses by the sketch.
The other thought was to instead store it in the code itself. I guess this would be done by using a hook to automatically update a header file "library" that is included by the sketch. e.g.:
#include <VersionTracker.h>
Now how do you access that information? You could have code in the sketch that sends out that information on request or startup. A simple example:
void setup() {
Serial.begin(9600);
Serial.print(F("Filename: "));
Serial.println(F(__FILE__));
Serial.print(F("Compilation timestamp: "));
Serial.println(F(__DATE__ " " __TIME__));
}
void loop() {}
Will print this information to the Serial Monitor on startup. Of course you could use any other method of communication. This sort of thing will add some significant overhead so it would perhaps be preferable (if less beginner friendly) to download the firmware from the microcontroller and then figure out a way to find the version information from the disassembly.
The time you cannot get. The Arduino doesn't have any clock or any way to know the time.
The code size you could get if you use AvrDude to read the hex code back off the chip and then just look at the size of what you read back.
I recently got one TFT LCD from aliexpress which supports SPI and uses ILI9341.
This is the one.TTT ILI9341
I have the ESP8266 EspressoLite 1 board, and I am using ESP8266 Arduino. (https://github.com/esp8266/Arduino)
I made the following connection :
I made the following connection : SCK #14, MOSI #13, MISO #12 and CS, #4, DC #5,RESET #0
and used the example graphicTest (which is available in the Adafruit_ILI9341-master folder) . I was able to make the display work for a few seconds. In the graphic test, once the line test starts my ESP8266 gets restarted. This was getting repeated .
In my existing project, I used the following code to just show some messages :
Adafruit_ILI9341 tft = Adafruit_ILI9341(4, 5, 13, 14, 0, 12);
tft.begin()
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_GREEN); tft.setTextSize(4);
tft.println(message);
The message is shown once a response is sent back from ESP. This works for a couple of times and then it again gets stuck and reboots.
I am not sure whether I am using the optimised library for ESP8266 for this LCD or whether there is any as such.
I read in forums and could see that there were some adafruit libraries in the ESP8266 Arduino but now that it is not available and only some TFT_Touch_Shield_V2 are present.
Has anyone faced the same issue or can tell me a better way to make this display work with ESP8266 Arduino.
Thanks in advance. !!!
Even i had somewhat the same problem.
There's a library called 'UTFT' which works fine on the device. Try using the library. Thats the best for esp and ILI9341.
Also, you can try using delay() or yield() functions in between.
The esp8266 may restart itself due to the watchdog when a loop a takes long time to process.
I am using Arduino Uno board and programming it with a Windows 10 system. From the tutorials on Arduino website, I am trying to upload the following code:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1);
}
It had undergone a series of issues:
First,
avrdude: ser_open(): can't open device "\\.\com3"
I searched for his issue, and found that most common solution is to go to device manager and change the name of the port, then unplug and plug again the arduino board. I did that
Second,
C:\Program Files (x86)\Arduino\hardware\tools\axr\bin\avr-ar:
unable to rename 'core.a'; reason: file exists\\
I thought it could be a memory problem. I used the reset button on the board, and repeated steps from the solution to the first problem. I tried to upload the code again.
But now, I am not getting any error message. But the problem is that it is taking forever to upload the code. I see Uploading... status since a long while. The green progress bar is also complete, but no uploading completed till now.
Any help to understand and solve this will be appreciated.
The solution for me was to disable Apple's Bonjour service with the task manager.
I would like to configure my serial communication to have no parity, 1 start- and 2 stop-bits. The documentation for Serial.begin(speed, config) states:
(...) An optional second argument configures the data, parity, and stop bits. The default is 8 data bits, no parity, one stop bit.
The documentation also lists the possible configuration-values. According to my (limited) understanding, I need SERIAL_7N2 or SERIAL_8N2 to meet my requirements. (I'm not sure how the data-bits relate to the the 1-start-bit that I need.)
However, I can't even compile because I have no idea how to supply that configuration value to the begin method. (I don't have much Arduino/C++ experience).
In my code, I've tried the following two variants:
Serial.begin(9600, SERIAL_8N2);
Serial.begin(9600, "SERIAL_8N2");
Am I missing something?
Additional information:
Serial.begin(speed, config) has been introduced with the latest Arduino 1.0.2 IDE version.
The code defining/implementing the begin methods can be found:
HardwareSerial.h
HardwareSerial.cpp
Edit:
According to the replies from PeterJ and borges, the following variant is correct.
Serial.begin(9600, SERIAL_8N2);
However, it's still not working.
I found that the compile error doesn't occur if I change the configured board from my Arduino Leonardo to Arduino Uno.
Therefore, it could be a bug occurring only with a subset of boards ... or maybe it's not supported?!
Edit 2:
It's now solved :) The answer of borges pointed me to the right solution!
You mentioned in a comment: (edit: and now is in the title)
I don't get the compile error if I change the board from my "Arduino Leonardo" to "Arduino Uno".
The Arduino Leonardo has some peculiarities regarding serial communication:
Leonardo has a microcontroller (ATmega32U4) that has native USB communication. To maintain compatibility as the entire ecosystem already established, the Leonardo virtualizes a serial communication over USB. You have access to this communication using Serial in the code. Physically you have access to that communication via the USB plug.
To use the "real" serial communication (AKA serial TTL), you need to use pins 0 (RX) and 1 (TX). In the code you would use Serial1 (notice the number 1!).
An example:
void setup() {
Serial1.begin(9600, SERIAL_8N2);
Serial1.println("Hello?");
}
void loop() {
}
For more information (recommended):
Arduino Leonardo
Guide to the Arduino Leonardo
The first method should be OK, so you have a compiler configuration or include problem. Make sure you have the following include at the top of your file:
#include <HardwareSerial.h>
Also while SERIAL_8N2 is valid it's an odd setting rarely used. You'll most likely want SERIAL_8N1.