Nextion Data Record Software(video 192)

We got a question from a viewer about converting the Data Record .data file into a .csv file. Our current video is taking a little longer than we thought. So, this is a great time to add another project to the list. The world’s most excellent programmer Ed Malloy decided to take a crack at this one. Not only is he a great coder, but he is also self-proclaimed hunky.

Thanks to the editor for that wonderful introduction, but I have never built an actual project in python, so I thought this would be a simple but helpful project. It turned into a more significant project than I thought. Skip about five paragraphs if you don’t care about my issues in developing this project.

I started last Wednesday and had it working with the IDE version of .data files. The IDE produces a file full of null values and data. So I figured I could calculate the record size based on the data and the addition of the nulls between each record. It worked like a charm. So I moved on to an actual display.

I uploaded the HMI file and created a random amount of records. The test did not work as expected. I got nothing. I opened the .data file, and it was not full of nulls. Not only was it not full of nulls, but it also contained data from old data record objects that I had created before. So I was back to square one.

I then created a new data record with 53(ASCII 5) records and a record length of 51(ASCII 3). I got the card from the physical display and figured out which bytes stored the configuration values. This took me into Friday. I was pretty happy at this point and full of confidence. I sent the code out to be tested, and once again, failure. Luckily the person sent me a copy of their HMI file and the .data file so I could take a look. A tweak here, a frustrated scream, and viola, it was pretty close.

I decided to use auto-py-to-exe. I figured an EXE file would look cool, so I compiled, built, zipped, and sent it. It got flagged as having a virus. I was able to confirm this on a secondary computer. What to do? Did my computer have a virus? So many questions. It turns out that this can happen when you create your code with auto-py-to-exe.

I had to remove all my ICO files. This stunk because I like my logo and thought having it as the icon would be cool. I figured it better to have something without a logo than nothing, so I repackaged it, and it still had a virus. I read a little more; this can happen if you run the auto-py code in a py file more than once. I created a new directory, copied my .py file to that directory, rebooted the computer, and reran the auto-py program. It appears to be working, and that brings me to today, Monday.

This software is for entertainment and evaluation only. Please beware it could cause instantaneous death if not used properly. In other words, please don’t sue me if it doesn’t work:-)

Click to download –> CC_DataRecord_V05Download <-- Please read below before using

A donation would be greatly appreciated. Click HERE to donate to the cause. Some of your contributions will go to saving the Flutterbird. The Flutterbird is essential to Sarah Jean, our lead engineer and all-around fabulous chick. HAHA! You should know by now I think that girl is nuts. You can read more about the elusive Flutterbird by clicking HERE. Now, back to the article.

You still get the following screen when you run it the first time. This is because I read some articles, and Cheap Controls would have to purchase a license, register the code, or do something that costs money. Unfortunately, Cheap Controls loses money monthly, so we are going with the free plan, which involves the following images.

protection warning
Click on the “More info” text

Then you have to click Run anyway. You can back out at this point, but remember, every time you run something written by Cheap Controls, a Flutterbird egg hatches.

protection warning
Press “Run anyway” if you want to use the software

I have included an image of the icon for the software. I was disappointed that I couldn’t include the Cheap Controls logo. I know the python logo is a snake, but on the bright side, it resembles a yellow peep which resembles a bird which resembles, you guessed it, a Flutterbird.

Data Record Software Icon
Icon for software

When you initially open the program, you get the image below. Next, press the “SELECT FILE” button and locate the .data file on your computer or external SD card.

Software Usage Step 1 & 3
Software Usage Step 1 & 3

Once you select the .data file, you should see the Current and New fields populate. You will also get the number of records and the size of each record. The size is determined in the Nextion IDE using the “lenth” attribute. Please note the record size displayed is one larger than the lenth attribute. At this point, you press the “CREATE FILE” button. Please note that you will overwrite a file if it has the same name as the new file and is in the selected directory. I ran the example below with 75,360 records.

Software Usage Step 2
Software Usage Step 2

Below is an image of the display if the software thinks everything when well.

Software Usage Step 1 & 3
Software Usage Step 1 & 3

I did an example of selecting the .csv file to show that you can choose any file, and it will attempt to do the process. In the case below, so many records were selected that the number goes off the dedicated area. This is an example of a Numb Recs that should signal a warning. However, I believe the Nextion Data Record can support millions of records. I will continue to test, and if necessary, I will alter the software as needed.

Wrong file selected
Wrong file selected

If all has gone well, you should have a CSV file for a spreadsheet program.

If you have read this far, you are a tremendous supporter of Cheap Controls and should be patting yourself on the back for being patient.