Start a new topic

Trouble with EEPROM to UART

Can I use wepo to load EEPROM with ASCII text and use rept to read the EEPROM data to the UART in hex?

 

Once the Nextion HMI is programmed via TF Flash and the EEPROM is loaded with data via laptop USB, then I need to attach the Nextion RX/TX pins to a TTL port on a signal generator. 

 

This is in order to create a user friendly touchscreen interface for a signal generator.

 

Currently I use Arduino to write commands to a 5V TTL interface using serial1.write.  This hex command represents the ASCII command dw2\n. 

Serial1.write(0x64); 

Serial1.write(0x77);

Serial1.write(0x32);

Serial1.write(0x0A);

 

I thought that I could store hex byte values 64 77 32 0A in the EEPROM from a text button that says dw2\n then I should be able to use 'rept' in my HMI logic to send the command to the TTL device using the UART pins. 

 

wepo "dw2\\n",1 // write string "dw2\n" to EEPROM, start from address #1. storage size is 5 bytes 

rept 1,5 // read 5 bytes of hex data from EEPROM to UART, start address is 1 


This doesn't do work to my TTL device that uses 5Vpp logic. I've tried a 5V to 3.3V logic level converter and still doesn't work.

 

Does wepo convert ASCII text and store it as hex bytes in EEPROM? How do I load hex data into EEPROM from on-screen text button so I can send the command from EEPROM to UART?


Please help me understand how to do this with no MCU required.



as stated in other thread - printh

Yes that was a lot easier! Thanks, it looks like I can use print in Arduino with HEX modifier too. That makes my Arduino code a lot easier. Thanks!

@Steven


Is there a particular reason why your HMI design needs to use the Nextion EEPROM for simple text storage and retrieval (to print)?


Any button component touch/release event code can achieve this just by including the printh in the said buttons code pane as appropriate.

image


This simple method hardcodes the print to a button press, the button would just need marking "dw2\n"

Repeat for as many buttons as you have commands for :)


And try not to overthink byte formats, they all go down the wire in the same format.

Serial1.write(0x64); 
Serial1.write(0x77);
Serial1.write(0x32);
Serial1.write(0x0A);

Can be sent just the same with

Serial1.print("dw2\n");

 or

Serial1.println("dw2");

or

Serial.print("\x64\x77\x32\x0A");

or even

char buffer [5] = {100, 119, 50, 10, 0};
Serial1.print(buffer);

  :)


Steve.



1 person likes this
Login or Signup to post a comment