payano / mMesh

Mesh implementation for embedded systems, focusing on a small footprint
MIT License
0 stars 1 forks source link

random number generator for generated addresses stm32 #33

Closed payano closed 4 years ago

payano commented 4 years ago

This is a must have in order to create random addresses for nrf24l01.

payano commented 4 years ago

In order to create randomness for addresses, reading the temp sensor might be the best way to generate enough randomness.

payano commented 4 years ago

HAL_ADC_Start(&hadc1); HAL_ADC_PollForConversion(&hadc1, 1000); adc1 = HAL_ADC_GetValue(&hadc1); HAL_ADC_Stop(&hadc1);

... something... sensorValue = adc1 * ADC_REFERENCE_VOLTAGE_MV / ADC_MAX_OUTPUT_VALUE; temperature = (int32_t)((sensorValue - TEMP_SENSOR_VOLTAGE_MV_AT_25) / TEMP_SENSOR_AVG_SLOPE_MV_PER_CELSIUS + 25);

payano commented 4 years ago

Fixed here: https://github.com/payano/mMesh/commit/d80ee51b9367224368ea48ecfab1f2339c100549