Raspberry Pi Linux LESSON 24: Running Python on the Raspberry Pi

If you have been following these lessons by this time you should be fairly comfortable with the Linux operating system, and you should know enough commands to do what you need to from the terminal window and command line. We now want to move forward to actually start doing things with the Pi. In order to do this, we will be using the Python programming language.

One thought on “Raspberry Pi Linux LESSON 24: Running Python on the Raspberry Pi”

  1. Hello sir, your lecturer are very nice. i learned a lot from these,,, However recently i was making a program using I2C to read my Melexis Mlx90614 themo sensor however, this is giving error., can you suggest something

    My program is this

    #!/usr/bin/env python3
    import math

    import Adafruit_GPIO as GPIO
    import Adafruit_GPIO.I2C as I2C

    class Melexis:

    def _init_(self, addr=0x5A, fahrenheit=False):
    self._i2c = I2C.Device(addr)
    self._mode = fahrenheit

    def readAmbient(self):
    return self._readTemp(0x06)

    def readObject1(self):
    return self._readTemp(0x07)

    def readObject2(self):
    return self._readTemp(0x08)

    def readTemp(self, reg):
    temp = self._i2c.readS16(reg)
    temp = temp * .02 – 273.15
    if self._mode:
    return (fahrenheit * 9 / 5) + 32
    return temp

    if _name_ == “__main__”:
    sensor = Melexis(fahrenheit=True)
    t = sensor.readObject1()
    a = sensor.readAmbient()
    print(“Object: {}F ({}F warmer than the ambient temperature)”.format(
    round(t, 3), round(t – a, 3)))

    Now this is giving error… that is

    Traceback (most recent call last):
    File “mmk01.py”, line 32, in
    sensor = Melexis(fahrenheit=True)
    File “mmk01.py”, line 11, in _init_
    self._i2c = I2C.Device(addr)
    TypeError: _init_() takes at least 3 arguments (2 given)

    (program exited with code: 1)
    Press return to continue
    Show less

Leave a Reply

Your email address will not be published. Required fields are marked *