Share your projects and post your questions
IO Pi Plus interrupt-driven input
w1_master_driver w1_bus_master1: Family 0 for 00.700000000000.f8 is not registered.
How to read temperatures using PT1000 with ADCPi ?
I2C pullup resistors
1462 Views - Created 26/01/2017
Im new to python but getting there writing for my project but am stuck on using the memory storage on the RTC using the example code. What am I mssing to store a number libe 0.0005
Last edited: 26/01/2017
Sorry - new to the forum as well
The RTC memory example would only work with whole numbers as it saved the value as an integer. I have created a new python script which shows how you can save a number with decimal places to the RTC memory. You can view the file at https://github.com/abelectronicsuk/ABElectronics_Python_Libraries/blob/master/RTCPi/demos/demo_rtcmemory_double.py
To save a number to the memory you have to convert it into an array of bytes. As the number you want to save is not a whole number it would have to be saved as a double which contains 8 bytes. I created two functions double_to_array() and array_to_double() that you can use to convert the number from a double into an array of bytes and back again.
Hopefully you can use this example to get your project working.
Thanks Andrew I now understand that bit.
If I wanted to run both of those functions under one function call and pass the varaiable into it, is that poosible?
Im having problems passing variables between functions and in and out of functions
Do you mean combine the code from both the functions into a single function or call both functions from another function? As the double_to_array() and array_to_double() functions take different data types as inputs, an array of bytes and a double, it would be difficult to make combine them together.
If you are having trouble passing variables then it may be worth reading this page on how functions work in python. The main cause of problems I normally find is trying to pass the wrong data type of number of arguments into the functions.
Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.