September 2019 Update

New! We're moving to the new forum!

ALL new Blog posts will be on the forum.

Please join us there.

This Blog will no longer be updated...

Saturday, July 6, 2019

Sensor Modules - Do I need Confirmation?

Each time a Sensor Module reads a sensor, and sends the data to the database, it also reads the record back to get it's record Id in the database as confirmation the record was written.

The steps involved are kinda complex...

Module is the code running on the Mega 2560
Server is the code running on the ESP 8266

Both are on the same board, connected by a hardware serial port.

The Server has the WiFi connection, and the Database code.

Here's the current process....

The Module requests the Sensor Configuration from the server via XML on the serial line. It then monitors the Serial line for a response...

The Server parses the incoming XML, and sees the request. It then does a SQL query to get a list of all sensors assigned to this module, and their configuration, and then sends it via the serial encoded in XML to the Module.

The Module, reads the response, and stores the configuration information in an array.

The module loops through each sensor in the array, and scans it, taking a reading.

Once it finishes scanning all the sensors, the Module then sends the data, one record at a time, via XML over the Serial line, to the Server, and then waits for a confirmation from the Server that each record was written.

The Server then loops through the sensors and writes the data to the database. After writing the record to the log, the Server attempts to read it back to get the record id, verifying that the record was written.

Once all the records are written, the Server sends a lits of Sensors and the record Id's back to the module

The Module displays these confirmations, but that's it, it doesn't actually do anything with the information...

Whew...   Ok, so here's what I've learned...

I was always seeing "Timeout waiting for confirmation..." and presumed there was an issue saving the data and responding on time.

However, it you look at the status lines I added to the terminal (grayed out) you will see that the number of module readings is equal to the number received by the server, and all of them were saved successfully.  The only issue seems to be the confirmation, somewhere around 20% of these confirmations are not coming back to the module properly even though they were saved properly.

This makes me question the point of even returning the confirmation...  I think now, having the status lines is more than enough for me to know whats happening. The information is not even being used, just displayed...  It causes a lot of traffic on the Serial Line as well.

If I remove it, I'll need to still wait for some confirmation that the Server has finishes it's tasks saving the data before the Module starts sending more data, or requesting something from the Server.

With all the traffic on the Serial line now, it will only be beneficial to reduce it as much as possible, especially if it really serves no useful purpose any more.

No comments:

Post a Comment

Any comments deemed off topic or offensive will be removed