-
Couldn't load subscription status.
- Fork 0
Sensor module firmware concept
The sensor module acts as a slave device on the internal I²C bus which responds to data requests from the main module, which acts as a master device. Internally, A sensor module should have variables to store the latest information from it's internal sensing device(s). The stored data should be updated at set intervals within the main loop code of the module.
Firmware Sequence Diagram

Upon startup, the sensor module performs all of its required initialization. Once that is complete, the module joins the I²C bus as a slave device with a certain address (see this page for details). Once all setup is complete, the module loops indefinitely, updating it's internal data storage variables while waiting for any requests from the main module. Upon request, all the latest data in the module will be sent over to the main module.
The data that is sent over the bus is all string based, only ASCII characters are sent. This allows the main module to be able to accept any type of information easily, along with making data transmission from sensor modules more straight forward. The data is sent in chunks of up to 32 bytes (or 32 ASCII characters). Each chunk can represent a key and a value for a data entry.
An example reply from a temperature and humidity sensor module would look like this
$temperature^ #25.00 c^ $humidity^ #50.00 %^
NOT DONE YET, KEEP EDITING THIS
This reply contains two types of data with one value for each type of data sent. In this example, a "temp" (temperature) value of 25.00°C and a "humid" (humidity) value of 50.00% are sent to the main module.
$ referred to as CH_DATA_NAME is used to specify that the following characters represent the actual type of data that is going to be transmitted (i.e temperature, light intensity, etc.)
# referred to as CH_DATA_BEGIN is used to specify that the following characters represent the value of the previous data type. This value could be numerical or alphabetical, depending on the desired output of the sensor module.
^ referred to as CH_TERMINATOR is a character used to terminate a field in the transmission
NOTE The terminator character MUST be appended to the end of both data type names and actual data values! A data value MUST have a data type name preceding it.
With the current implementation of the firmware, data can only be sent in a single request from the main module, this means that there is a 32 character limit (including control characters) to the data that you can send.
The main module will also only accept ASCII characters being sent to it (C char type), any other primitive data type sent to it will result in errors.
It is also a good idea to name data types with as few characters as possible to avoid unnecessary character usage.