A micropython exapmle for DS2413 chip

Connection diagram of the Simple Smart Home system extension module to the esp32 devkit board:                                                                                                    


Micropython provides an easy and quick start for simple tasks, as well as to explore the capabilities of IoT devices, all the main interfaces of microcontrollers, such as I2C, OneWire, GPIO, ADC, PWM, etc. We will consider examples based on the esp32 devkit ver.1 board with Micropython firmware for this microchip and devices presented on our website.                                                                                                    

The following are the texts of the three files that must be placed on the device’s file system using the micropython IDE, e.g. Thonny .
boot.py - it is executed during the boot of micropython, in this example we are connecting to the WiFi network.
main.py - the main program that implements the logic of the device. In the example, the status of the button connected to channel A of the device and, if pressed, the relay status (channel B) switches to the opposite.
ds2413.py - library for working with the relay extension module / sensor.                                                  

  • boot.py
  • main.py
  • ds2413.py