Skip to content

Search the documentation

Kit
Firmware

home

Smart Home

The MoBot Smart Home: every part of the house is reached through this object, home.

This page is for the Smart Home, on firmware 3.0. Click a class in the table to see what it can do. See also: the Smart Home kit, its examples and the names that changed from 2.x.

Every part of the house is an attribute of home. The class tells you what the part can do. Read Attributes that can be None to see what “can be None” means.

Attribute What it is Class
home.temperature_sensor Measures the temperature in degrees Celsius and how much water vapour is in the air (humidity, in percent). TemperatureSensor
home.motion_sensor Notices a person or an animal moving nearby. Warm bodies give off infrared light we can’t see, and the sensor reacts when that light moves. MotionSensor
home.gas_sensor Notices gases and smoke in the air. A tiny heated plate changes how well it conducts electricity when those gases touch it. GasSensor
home.light_sensor Measures how bright it is: a special resistor lets more electricity through when more light falls on it. LightSensor
home.knob Reads how far the knob is turned. Knob
home.button The house’s push button. Button
home.battery Measures the battery’s voltage, which drops as the battery empties. Battery
home.rfid Reads the number of a card or tag held close to it. The reader powers the card with radio waves and the card answers with its number. RFIDReader (can be None)
home.rgb_led The house’s colour lamp; colours are red, green and blue from 0 to 255. RGBLed
home.display The house’s screen: 128 x 64 dots, x from 0 (left) to 127, y from 0 (top) to 63. Display (can be None)
home.number_display The house’s three-digit number display. NumberDisplay (can be None)
home.buzzer The house’s buzzer; frequencies are in hertz and durations in milliseconds. Buzzer
home.servo The house’s servo motor (the door); angles are in degrees, 0 to 180. Servo
home.fan The house’s fan; its speed is in percent, 0 to 100. Fan
home.wifi The house’s Wi-Fi: its address, its name and the networks it remembers. Wifi
home.dashboard The house’s web page: the readings, and the switches, sliders and boxes a program adds. Dashboard

In the table, a class followed by (can be None) means that the attribute holds either an object of that class or None, which is Python’s word for “nothing”. Written as a type, such an attribute is Optional[...], for example Optional[RFIDReader]. If your program uses a part that is None, it stops with an AttributeError. The attributes with no such mark are always there.

A part of the house is None when:

  1. You have to switch it on first.
  2. The part did not start. When the house starts, it sets up the RFID reader and the screen. If one cannot start, the house prints a message such as Error initializing RFID: and carries on. The attribute is None.

To be safe, check before you use a part:

if home.rfid is not None:
home.rfid.read_card()

Switches on the three-digit number display, home.number_display (start-up already does it).

home.enable_number_display() -> Optional[NumberDisplay]

These functions are not part of home. Import them at the top of your program:

from mobot import map_range, sleep_ms

map_range(value, in_min, in_max, out_min, out_max)

Section titled “map_range(value, in_min, in_max, out_min, out_max)”

Converts a value from one range to another, for example 0-1023 to 0-100; the result is a float.

map_range(value, in_min, in_max, out_min, out_max) -> float

Waits ms milliseconds.

sleep_ms(ms)