Device calibration#
Overview#
These notes group together various tips and tricks for calibrating and coding the sensors and actuators for your project.
To just make progress on A2/M4#
Sensors#
Make a file very similar to the one I made for the aht20, suggestions:
name the python file after the device, for e.g.,
tmg39931.pyfor the the TMG39931.make a Mock class very similar to the
MockGrove...class I made, e.g.MockTMG39931(for now) have it inherit the same
Grove...class, since it’s also an I2C-using module, the behaviour is similar enough for us to be happy, we can replace it laterEnsure you use the correct default bus (1) and address (depends on the device)
define a read method that returns a tuple with random numbers for all the readings
Make a
Sensorclass for each reading in a similar style to my Temperature and Humidity sensorsthe
devicetype should be the same (Grove...), so it can be the same type as your Mock class.the
measurementshould be a newMeasurementtype you create for that device.
Use your new
Sensorclasses the same way I used the Temperature and Humidity ones, that is, make sure thedevicecontroller gets them when the system is initiatedYou can now do everything you need to do to meet 100% of the A2/M4 requirements
To get the device working#
I2C devices#
Use one of the three ports labelled “I2C” on your raspberry pi, plug the sensor in
on your reterminal, run
i2cdetect -y 1. The devices’ address should be “in use” once the device is plugged inSee if you can get readings from the device using python. Try to find an example using the device in python
To use the device in your project code#
Sensors#
Make a new device class (e.g.
TMG39931class in your device file e.g.tmg39931.py. It’s going to be really similar to theGrove...class in thegrove.pylibrary, except:__init__: the same, but use the correct default address and bus.read: same idea, but customize according to the previous steps where you got readings from the device.
Make your
Mockclass inherit from your new class insteadMake your
Sensorclasses use your new class as thedeviceinstead