Nextion no response - arduino

Hello I have been making a project with arduino and nextion but when I run it the nextion does not respond like it turns on and works like normal but it does not show any change to the screen the arduino controls it.
The code of arduino:
#include <Nextion.h>
NexText tb = NexText(0,4,"tb");
NexPicture eye = NexPicture(0,3,"eye");
void setup() {
eye.setPic (6);
tb.setText ("loading");
delay(1000);
eye.setPic (1);
tb.setText ("loaded");
delay(500);
tb.setText ("HelloWorld");
}
void loop() {
eye.setPic (1);
delay(1000);
eye.setPic (6);
delay(500);
}
I copied some of the code from the internet but it looks like somthing is wrong.
Disconnected and reconnected the nextion
Reseted the arduino multiple times
Checked and compiled the arduino code
Checked any errors in nextion
None of this works so please help ᓚᘏᗢ

It looks like your code is missing a setup call to nexInit(). Check these release notes or the homepage.

Related

input !== output signal - why?

I'm using a STM32G431KB Nucleo board (nucleo_g431kb - 170MHz) with PlatformIO & the Arduino framework.
My simple code looks like this:
void setup()
{
pinMode(PA11, INPUT);
pinMode(PA12, OUTPUT);
}
void loop()
{
if (digitalReadFast(PA_11) == HIGH) {
digitalWriteFast(PA_12, HIGH);
}
else {
digitalWriteFast(PA_12, LOW);
}
}
On pin 11 I got a well defined input signal like shown in the picture below (yellow signal). The blue signal in the picture is the one from the STM32 (pin 12).
Now the blue signal is not that defined like the yellow one. In theory, they both should be identical, shouldn't they? How do I get the output signal mirroring the input signal? The chip should have enough power. I tried a pull-down resistor, but it didn't change anything. I guess, I'm simply stupi.
Try internal pullup resistor such as
pinMode(PA12, OUTPUT_PULLUP);
Also try changing the output pin as a test because it seems like something else( some other process) is trying to also trying to pull same output pin.

arduino uno with PWM driven motor and 433mhz wireless receiver don't work

I am fairly new to the arduino topic and try to get a few things to work together.
First i tried setting up a DC motor that can be controlled via PWM, which works perfectly when used standalone. I can start/stop the motor and change speed depending on the value i send to the PWM pin.
Second i tried to use an RF-5V wireless receiver to work with a remote control from remote switched power outlets. For this one i followed the instructions on how to build a 433mhz sniffer.
This all by itself works as well. I can receive diffent codes depending on which keys on the remote i am pressing.
Now the fun part started: I wanted to integrate both of the projects into one, so i could use the remote to start/stop the motor.
So i came up with the following circuit:
(Thanks for some of you pointing out that the circuit does not match the sketch. I made an error when drawing, but even with the cables attached to the right pins, it works as described)
and the following code (which is partly from the instructions mentioned above):
#include <RCSwitch.h>
// init 433MHz lib
RCSwitch mySwitch = RCSwitch();
unsigned long lOldValue=0; // to check for consecutive reads on 433MHz
int motorPin = 5; // PWM-Pin to use for motor
void setup()
{
pinMode(motorPin, OUTPUT);
Serial.begin(9600);
// set-up rf receiver
mySwitch.enableReceive(0); // 433MHz Receiver on interrupt 0 => that is pin #2
}
void loop()
{
if (mySwitch.available())
{
int value = mySwitch.getReceivedValue();
// only react, if at least two times same value received
if (value == lOldValue)
{
if (value == 0)
{
Serial.print("Unknown encoding");
}
else
{
Serial.print("Received ");
Serial.print( mySwitch.getReceivedValue() );
Serial.print(" / ");
Serial.print( mySwitch.getReceivedBitlength() );
Serial.print("bit ");
Serial.print("Protocol: ");
Serial.println( mySwitch.getReceivedProtocol() );
// One of the keys on the remote
if (value == 274393) {
Serial.println("got start code, starting motor");
analogWrite(motorPin, 100); // start the motor
}
// another key on the remote
if (value == 270384) {
Serial.println("got stop code, stopping motor");
analogWrite(motorPin, 0); // stop the motor
}
}
}
lOldValue = value;
mySwitch.resetAvailable();
}
}
when i run the code and click on the remote, i get different values shown depending on the key i press. So the wireless receiver works as expected.
When i receive the right value for starting the motor, the motor really begins to turn, so this works as well.
And here the fun part starts:
As soon as i use the analogWrite function to send data to the PWM port the motor is connected to, the wireless receiver stops working (or at least I do not get any more values when pressing a key on the remote).
I found a few similar posts/problem descriptions on the net which said to try the following:
Use another pin for PWM (due to possible interrupt conflicts). I tried that as well, same behaviour
Use external power supply instead of USB-Cable, which helped somebody resolve this issue. Not here. Does not work either
So the question is:
Does anybody know how to combine those two things together so a can use the wireless receiver to get commands and switch on/off the motor with it?
I have the same problem in the past. The problem is the ability of arduino to supply them both. I recommend to use external power supply for the receiver or for the motor (it's best to do that for the motor but according to your circuit it's impossible) like the 545043YwRobot and supply the other from the arduino (I hope this is not what you try already, if so i'm sorry).
Hope it's help.
Yoav

Arduino doesn't turn off vibration after inputting 0

I have arduino UNO with bluetooth module and vibration motor attached. I can turn on the vibrator but cant seem to turn it off. Here's the code
#include<SoftwareSerial.h>//import the serial library
int vib=8;
SoftwareSerial Genotronex(10,11);//RX,TX
int BluetoothData;//the data given
void setup() {
Genotronex.begin(9600);
Genotronex.println("Bluetooth on please press 1 to vibrate");
pinMode(vib,OUTPUT);
// put your setup code here, to run once:
}
void loop() {
if (Genotronex.available()){
BluetoothData=Genotronex.read();{
if(BluetoothData='1'){
digitalWrite(vib,'1');
Genotronex.println("Vibrator on");
delay(500);
}
else if (BluetoothData='0'){
digitalWrite(vib,'0');
Genotronex.println("Vibrator off");
delay(500);
}
}
}
delay(100);
// put your main code here, to run repeatedly:
}
In the bluetooth terminal, it stated
<1> Vibrator on
when i input '1'
but also stated
<0) Vibrator on
when i input '0' when it should've been Vibrator off.
Appreciate all the help
if(BluetoothData='1'){
^
Single = is assignment. Use == for comparisons.
Also, BluetoothData should probably be defined as a local variable in loop(). It'll work either way, but will compile to slightly more efficient (and more readable!) code.

MeetAndroid with SoftwareSerial issue

I use Amarino with SoftwareSerial (from here: http://www.double-oops.org/mini-blog/amarinowithsoftwareserial ) but I have a strange issue.
It seems that there are some strange behaviour in the MeetAndroid Library. In order to receive events I had to make this changes:
in init() I had to change
ack = 19;
with
ack = 226;
because this is the char I received from the phone at the end of a message
and in receive() I had to change
uint8_t lastByte;
with
char lastByte;
otherwise the
if(lastByte == ack)
won't be true ever
Does anyone have any idea why I had this problems? Why do i get another ack char and why is the if not working for char (ack) and uint8_t (lastByte)
This is my sketch:
/*
Receives Test Events from your phone.
After it gets a test message the led 13 will blink
for one second.
*/
#include <MeetAndroid.h>
#include <SoftwareSerial.h>
MeetAndroid meetAndroid(4, 2, 115200);
int onboardLed = 13;
void setup()
{
meetAndroid.registerFunction(testEvent, 'A');
pinMode(onboardLed, OUTPUT);
digitalWrite(onboardLed, HIGH);
}
void loop()
{
meetAndroid.receive(); // you need to keep this in your loop() to receive events
}
void testEvent(byte flag, byte numOfValues)
{
flushLed(300);
flushLed(300);
}
void flushLed(int time)
{
digitalWrite(onboardLed, LOW);
delay(time);
digitalWrite(onboardLed, HIGH);
delay(time);
}
I found the problem, it is baudrate related. When using software serial I have to use a lower baudrate (9600 for example), otherwise when receiving multiple characters at once it won't work. And since amarino library sends multiple library at once (signaling the start and the end of the message for example) it caused problems when using software serial on slower hardware (like the Arduino Uno used by me). Probably with better hardware (Arduino Mega) changing the baudrate is not necessary.
Example for changing the baudrate is available here:
Receiving multiple chars at once with Software Serial
Long answered short:
When using SoftwareSerial on slower hardware use a low baudrate (like 9600). Also make sure to set the bluetooth board work on the lower baudrate.

I²C with energia and EK-TM4C1294XL

I want to communicate with a SHT21 Sensor from a EK-TM4C1294XL Board.
But it seems that I2C communication is quite difficult with energia.
I used different setups with external Pullup, used the internal pullup and also no pullup. then i tried both I2C interfaces by setting Wire.setModule(0) or Wire.setModule(1) but in all cases the result is that either everything freezes in the Wire.endTransmission() function or i receive only bytes filled with 0.
I basically used this library: https://github.com/elechouse/SHT21_Arduino and modified the example script like this:
#include <Wire.h>
#include <SHT2x.h>
void setup()
{
Wire.setModule(1); // SCL = PN_5 (pin 49), SDA = PN_4 (Pin 50)
Wire.begin();
// optional use this:
// pinMode(PN_5, INPUT_PULLUP);
// pinMode(PN_4, INPUT_PULLUP);
Serial.begin(115200);
}
void loop()
{
Serial.print("Humidity(%RH): ");
Serial.print(SHT2x.GetHumidity());
Serial.print(" Temperature(C): ");
Serial.println(SHT2x.GetTemperature());
delay(1000);
}
There is a boosterpack containing the SHT21 as well, but i did not found any sample code for that... I did not managed yet to get the C stuff running on my linux machine, probably I2C is broken in the energia lib?
Edit: it seems that there is a bug in the library too. The timing must be precise and also 3 bytes are requested and only 2 read. when reading the last byte i do not get good values but at least the loop does not freeze.

Resources