====== [[https://www.raspberrypi.org/products/raspberry-pi-zero-w/|Raspberry PI Zero W]] ====== Initial SD card setup: * Add to ''cmdline.txt'' to enable Ethernet-over-USB: \\ ''modules-load=dwc2,g_ether'' * Create empty file ''ssh'' to start SSH server automatically Initial server setup: * [[https://unix.stackexchange.com/questions/401359/|Install x11vnc]]: # apt-get install x11vnc $ x11vnc -storepasswd # echo 'su -l -c "x11vnc -rfbauth /home/pi/.vnc/passwd" pi' * Other packages: ''apt-get install vim tmux'' * [[habrahabr>488120|Почему на Raspberry Pi4 стоит поставить 64-битную ОС]] ====== [[http://www.arduino.cc/|Arduino]] ====== {{https://components101.com/sites/default/files/component_pin/Arduino-Nano-Pinout.png?800|Arduino Nano pinout}} {{https://ae01.alicdn.com/kf/HTB14XVaKxnaK1RjSZFtq6zC2VXaC.jpg?500|Arduino RF-Nano pinout}} {{https://lastminuteengineers.com/wp-content/uploads/iot/WeMos-D1-Mini-Pinout.png?600|ESP8266 WeMos D1 mini}} [[https://done.land/components/microcontroller/families/esp/esp32/s2/s2mini/|{{https://www.studiopieters.nl/wp-content/uploads/2022/08/WEMOS-ESP32-S2-MINI.png?600|ESP32 S2 mini}}]] {{https://www.teachmemicro.com/wp-content/uploads/2018/04/NodeMCUv3.0-pinout.jpg?500|NodeMCU V3 pinout}} {{https://i.imgur.com/zEoWhQk.png|NodeMCU V1 / V2 / V3 pinout}} {{https://i1.wp.com/microcontrollerslab.com/wp-content/uploads/2019/05/ESP8266-Modules.jpg?800|ESP8266 models}} {{https://i.imgur.com/zzgdvLr.jpg?600|Wemos D1 mini versions}} * http://arduino-ru.blogspot.nl/ * [[http://wiki.amperka.ru/|Видеоуроки по Arduino]] * [[http://arduino-projects.ru/]] * [[habrahabr>123236|Мини-обзор Arduino-совместимых плат различных архитектур]] * [[http://amperka.ru/|Магазин комплектующих]] * [[http://www.cashdollar.org/2012/09/13/battle-of-the-embedded-world-microcontrollers-vs-system-on-a-chip/|Microcontrollers vs System on a Chip]], [[http://www.cashdollar.org/2012/11/01/are-microcontrollers-obsolete/|Are Microcontrollers Obsolete?]] ([[habrahabr>158573|Микроконтроллеры устарели?]]) * [[habrahabr>274601|Советы начинающим программистам микроконтроллеров]] * [[habrahabr>123791|STM32F1xx — лечимся от ардуинозависимости вместе]] * [[http://www.chipdip.ru/video/?tag=arduino|Видео на chipdip]] * [[http://arduino.cc/forum/index.php/topic,146315.0.html|Arduino UNO Pinout Diagram]] * [[https://frightanic.com/iot/comparison-of-esp8266-nodemcu-development-boards/|Comparison of ESP8266 NodeMCU development boards]] * [[http://www.sunsky-online.com/product/default!search.do?keyword=arduino|Arduino items for sale]] * [[http://www.icstation.com|ICs & Robot Gadgets]] * [[github>Andrea-Fox/peopleCounter|People counter]] for ESP32 based on distance sensor. * [[youtube>7h2bE2vNoaY|How To Pick the right pins on the NodeMCU ESP8266 and ESP32]] and [[https://randomnerdtutorials.com/esp32-pinout-reference-gpios/|ESP32 Pinout Reference: Which GPIO pins should you use?]] * [[http://arduino.ru/Reference/|Программирование Ардуино]] * [[habrahabr>236673|Голосовое управление Arduino средствами Processing и Google Speech API]] * [[habrahabr>257867|Робот-пылесос своими руками]] * [[youtube>t2NgA8qYcFI|Upgrade Your Old Roomba to a Smart BotVac for $5]] * [[youtube>gXF0VDY7DHI|Top 10 Arduino Projects 2020]] :INFO: When selecting ATmega328 vs ESP8266 based solution, consider that ATmega328 would need 5V sensors, but ESP8266 would need 3-to-5V step-up when controlling LEDs. :INFO: ESP8266 has D3 / GPIO0 and D4 / GPIO2 10k pull-up + D8 / GPIO15 10k pull-down resistors, see [[https://www.wemos.cc/en/latest/d1/d1_mini.html|LOLIN D1 mini description]]. ^ Name ^ Price ^ CPU ^ CPU clock ^ Flash ^ SRAM / PSRAM ^ Networking ^ Power ^ Interface ^ [[wp>Pulse-width_modulation|PWM]] ^ [[wp>Digital-to-analog_converter|DAC]] ^ Notes | | Arduino Nano v3.0 | [[aliexpress>32980796969|€3.60 + €0.92 = €4.52]] | ATmega328P | 16Mhz | 32KB | 2KB | :NO: shield costs [[aliexpress>32831552462|€2.51 + €0.67 = €3.18]] | 5..12V | MiniUSB | :YES: | :YES: | | | LoLin NodeMCU V3 | [[aliexpress>33039992511|€1.89 + €0.88 = €2.77]] | ESP8266 | 80MHz | 4MB | 64KB | 2.4GHz WiFi 802.11 b/g/n | 3.3..12V (e.g. 3.7V LiIon) | MicroUSB | :YES: | :NO: | | | Wemos D1 mini V1 | [[aliexpress>32831353752|€1.76 + €0.66 = €2.42]] | ESP8266 | 80MHz | 4MB | 64KB | 2.4GHz WiFi 802.11 b/g/n | 3.3..12V (e.g. 3.7V LiIon) | MicroUSB | :YES: | :NO: | | | Wemos D1 mini Pro V1.1 | [[aliexpress>32831353752|€2.67 + €0.65 = €3.32]] | ESP8266 | 80MHz | 16MB | 128KB | 2.4GHz WiFi 802.11 b/g/n | 3.3..12V (e.g. 3.7V LiIon) | MicroUSB | :YES: | :NO: | | | Wemos ESP32-S2 Mini | [[aliexpress>32831353752|€2.69]] | | 240MHz | 4MB | 320KB / 2MB | 2.4GHz WiFi 802.11 b/g/n | 5V (USB) | USB-C | :YES: | 2× (GPIO17+18) | | | ESP32-C3 SuperMini | €2.39 | ESP32C3FN4 | 160MHz | 4MB | 400KB | 2.4GHz WiFi 802.11 b/g/n, Bluetooth 5.0 | 5V (USB) | USB-C | :YES: | 4× | 43µA in deep sleep, 22.5×18 mm | | ESP32-C6 | €12.45 | ESP32C6FH4 | 160MHz | 4MB | 512KB HP + 16KB LP | Wi-Fi 6 (2.4 GHz), Bluetooth 5.0 (LE), Thread (802.15.4) | 5V (USB) | USB-C | :YES: | 7× | 26×18 mm | Check: * [[http://www.monohelixlabs.com/wemos-d1-mini-pro-esp8266.html|Getting started with WeMos D1 mini and WeMos D1 mini PRO]], [[https://www.reddit.com/r/esp8266/comments/7e0tkm/help_on_wemos_d1_mini_versions_please/|Wemos D1 mini versions]] and [[https://arduino-projekte.info/unterschied-wemos-d1-mini-vs-d1-mini-pro/|Unterschied Wemos D1 mini vs. D1 mini Pro]]. * [[youtube>hjRSwBcLcSU|Arduino comparison guide]] Arduino clones need FTDI CH430 drivers from [[http://www.wch.cn/download/ch341ser_zip.html|here]] (''[[http://www.wch.cn/downloads/file/5.html|CH341SER.ZIP]]''). ===== ESP ===== * [[https://esphome.io/|ESPHome]] is a tool which reads in a YAML configuration file (just like Home Assistant) and creates a custom firmware binary. The tool also has many helpers that simplify flashing devices (uploading the new binary file) and aim to make managing your ESP boards as simple as possible. * [[https://easyeda.com/Alex_AW|ESP DIY (@Alex_AW / Александр Вайдуров)]] * [[hass>connect-nodemcu-esp8266-to-buildin-mosquitto-addon-in-hassio-using-tls/94353|Connect NodeMCU (ESP8266) to buildin Mosquitto Addon in Hassio using TLS]] * [[https://templates.blakadder.com/|Tasmota]] -- alternative firmware for ESP-based IOT devices that adds extra functionality to them * [[github>White-SinSay/UWC|Мультимодульная плата для Wemos D1 ESP8266]] * [[http://nutsandboltsandflyingsparks.blogspot.com/2023/05/fixin-glitchin-esp8266.html|Fixin’ a Glitchin’ ESP8266 (or How to use two FNB58 as a Dual Channel Oscilloscope)]] -- adding the 100uf capacitor on 3.3V rail significantly improves voltage and current response thus adding to stability, another step is to replace the default (underpowered) linear regulator with TPS73633 or RT9013. ===== LED strips ===== {{https://cdn-learn.adafruit.com/assets/assets/000/030/892/medium800/leds_Wiring-Diagram.png?500|Connecting LED strip to Arduino (5V data)}} [[https://hackaday.com/2017/01/20/cheating-at-5v-ws2812-control-to-use-a-3-3v-data-line/|{{https://hackaday.com/wp-content/uploads/2017/01/ws-levelshift.png?800|Cheating At 5V WS2812 Control To Use 3.3V Data}}]] [[https://www.superlightingled.com/blog/sk6812-vs-ws2812b/|{{ https://www.superlightingled.com/blog/wp-content/uploads/2022/06/SK6812-vs-WS2812B-2.jpg?800|SK6812 VS WS2812B}}]] * [[github>Makuna/NeoPixelBus|NeoPixelBus]] -- a library to control one wire protocol RGB and RGBW LEDs like SK6812, WS2811, WS2812 and WS2813 * [[https://www.seeedstudio.com/blog/2019/02/14/ws2812b-vs-ws2813-addressable-rgb-led-strips-how-are-they-different/|WS2812B vs WS2813 Addressable RGB LED Strips – How are they different?]] * [[https://www.tweaking4all.com/hardware/arduino/arduino-ws2812-led/|Controlling a WS2812 LED strand with NeoPixel or FastLED]] * [[https://www.tweaking4all.com/hardware/arduino/arduino-all-ledstrip-effects-in-one/|Arduino – All LEDStrip effects in one]] * [[youtube>YgII4UYW5hU&t=526|How to calculate real energy consumption of the LED strip]] * [[youtube>ZFO_QOBG9Bs&list=PLL02pNmOcO9lmMIQXaxv0_3oXM_l-yb-8|Answers to the most common DIY LED questions]] -- 1000 LEDs on one PIN, 35mA per LED, max 60 cm data line (can be boosted up to 40 meters if using sacrificial LED) * [[github>kitesurfer1404/WS2812FX|A library that features a variety of blinking effects for the WS2811/WS2812/NeoPixel LEDs]] * [[youtube>2FXs1arWMrE|demo]] * [[youtube>QnvircC22hU|LED Strips, what's the difference? WS2811, WS2812B, 2812Eco, WS2813, WS2815, SK6812, SK9822]] ([[https://www.thesmarthomehookup.com/the-complete-guide-to-selecting-individually-addressable-led-strips/|text version]]) * [[youtube>_UiqrnRiqpk|Year Round Holiday LEDs, part1]], [[youtube>Q8w56sOnadU|part 2]], [[youtube>UWb2i6BHx1g|part 3]] * [[github>thehookup/Holiday_LEDS/blob/master/LightsMCU_CONFIGURE.ino|LED effects sketch Arduino library]] * [[youtube>x9sKEABf8IY|Setting up multiple LED wifi control boards]] * [[https://quinled.info/addressable-digital-leds/|Addressable COB LED strip guide]] ===== Smart meter ===== {{https://ae01.alicdn.com/kf/HTB1Z7hnXznuK1RkSmFPq6AuzFXal.jpg?500|P1 port (ESMRv5.0 P1) pinout}} [[github>daniel-jong/esp8266_p1meter#connecting-to-the-p1-meter|{{https://raw.githubusercontent.com/daniel-jong/esp8266_p1meter/master/assets/esp8266_p1meter_bb.png?500|Connecting ESP8266 to the P1 meter}}]] {{ https://i.imgur.com/AQURxfj.jpg?500|Logical inverter based on BS170}} [[github>renearts/ESP8266-P1-transmitter/blob/master/P1port.png|{{ https://wiki.pieper.eu/wp-content/uploads/2016/03/P1port.png?500|Logical inverter based on BS170 with additional resistor}}]] * [[https://thinkpad.tweakblogs.net/blog/10673/uitlezen-van-de-slimme-meter-p1-poort-met-een-arduino-en-waarden-opslaan-in-mysql-database|Uitlezen van de slimme meter P1-poort met een Arduino en waarden opslaan in MySQL-database]] * [[https://gathering.tweakers.net/forum/list_messages/1578510/0|Slimme meter uitlezen via P1-poort]] * [[https://willem.aandewiel.nl/index.php/2018/08/28/slimme-meter-uitlezer/|Slimme Meter uitlezer]] * [[https://www.home-assistant.io/components/sensor.dsmr/|DSMR plugin for HASS]] * [[github>fliphess/esp8266_p1meter|ESP2866 module that sends P1 smart meter data to MQTT broker]] * [[https://community.home-assistant.io/t/p1-monitor-or-dsmr-slimme-meter-integration/352903/3|‘P1 Monitor’ or ‘DSMR Slimme Meter’ integration]] * [[https://tasmota.github.io/docs/P1-Smart-Meter/|Tasmota P1 Smart Meter]] * [[http://domoticx.com/p1-poort-slimme-meter-uitlezen-hardware/|Different ways to connect P1 port to Arduino]], [[http://domoticx.com/p1-poort-slimme-meter-hardware/|P1 poort slimme meter (hardware)]] * [[github>matthijskooijman/arduino-dsmr|Arduino Dutch Smart meter (DSMR) parser]] Challenges: * [[github>PaulStoffregen/AltSoftSerial/issues/37#issuecomment-576463200|Pin 8 is used by Ethernet Shield ENC28J60]] ESPHome installation: * [[https://esphome.io/guides/getting_started_command_line#bonus-esphome-device-builder|Install ESPHome from docker]] and open [[http://localhost:6052/]]: # docker run --rm --net=host --privileged -v "$(pwd):/config" esphome/esphome * Paste the following configuration then press //Install → Manual Download// which will compile the firmware and offer ''smart_meter.bin'' file which should be saved locally: esphome: name: smart_meter friendly_name: "Smart meter" esp8266: board: d1_mini # For complete list check https://registry.platformio.org/platforms/platformio/espressif8266/boards logger: hardware_uart: UART1 # D4 on D1 mini tx_buffer_size: 4096 ota: - platform: esphome password: "" api: # Expose API for Home Assistant integration wifi: ssid: "" password: "" substitutions: mqtt_prefix: "smart_meter" mqtt: broker: 192.168.1.10 username: "" password: "" topic_prefix: "${mqtt_prefix}" log_topic: "${mqtt_prefix}/logs" keepalive: 300s # Otherwise MQTT client reconnects every 15 seconds uart: rx_pin: GPIO3 # RX pin on D1 mini baud_rate: 115200 rx_buffer_size: 1500 # A bit bigger than P1 message size sensor: - platform: dsmr power_delivered: name: "Power Currently Consumed" state_topic: "${mqtt_prefix}/power_consumed" power_returned: name: "Power Currently Produced" state_topic: "${mqtt_prefix}/power_returned" voltage_l1: name: "Voltage L1" state_topic: "${mqtt_prefix}/voltage_l1" current_l1: name: "Current L1" state_topic: "${mqtt_prefix}/current_l1" energy_delivered_tariff1: name: "Total Energy Consumed Tariff 1" state_topic: "${mqtt_prefix}/energy_consumed_tariff1" energy_delivered_tariff2: name: "Total Energy Consumed Tariff 2" state_topic: "${mqtt_prefix}/energy_consumed_tariff2" energy_returned_tariff1: name: "Total Energy Produced Tariff 1" state_topic: "${mqtt_prefix}/energy_returned_tariff1" energy_returned_tariff2: name: "Total Energy Produced Tariff 2" state_topic: "${mqtt_prefix}/energy_returned_tariff2" * Open https://web.esphome.io/ in Chrome, press //Connect// and choose the appropriate COM port ESP8266 is connected to. Press //Install → Choose file//, select previously downloaded ''smart_meter.bin'' and press //Install//. * After 1st installation it is possible to update firmware wirelessly using OTA (choose //Wirelessly//). ESPHome installator will automatically display logs using API connection. * Alternatively one can monitor logs using ''mosquitto_sub -v -t 'smart_meter/#' -u aaa -P bbb'' Network: [[http://foreglance.com/20140822/arduino-as-web-server-with-simple-web-page/|{{https://robotdyn.com/pub/media/0G-00004976==NanoEthENC28J60-Shield/DOCS/PINOUT==0G-00004976==NanoEthENC28J60-Shield.jpg?500|Ethernet Shield ENC28J60 pinout}}]] * [[http://www.esp8266thingies.nl/|P1-WiFi gateway based on ESP8266 board]] * [[https://www.tweaking4all.com/hardware/arduino/arduino-enc28j60-ethernet/|Web-Enable your Arduino with an Arduino ENC28J60 Ethernet shield]] (more examples: [[github>consolacion/ENC28J60-MQTT/blob/master/enc28j60MQTT_uni/enc28j60MQTT_uni.ino|publishing the state of pins via MQTT]], [[http://domoticx.com/enc28j60-ethernet-module-mqtt-voorbeeld/|publishing BME280 temperature readings via MQTT]], [[http://domoticx.com/?s=p1+poort|more…]]) * [[habrahabr>249335|Подключаем Ethernet ENC28J60 через SD card-reader для WEB сервера на Arduino]] * [[github>ledongthuc/CustomSoftwareSerial|CustomSoftwareSerial]] library supports many modes including 7E1 and 8N1. * [[http://domoticx.com/p1-poort-slimme-meter-hardware/#tablepress-766|Kaifa MA105C / DSMR 4.2.2: 115200 8N1]] * [[https://gathering.tweakers.net/forum/list_message/43857676#43857676|DSMR 4.0: 115200 8N1]] * [[http://gejanssen.com/howto/Slimme-meter-uitlezen/index.html|DSMR 4.1/4.2: 115200 7E1]] * Similar problem [[https://gathering.tweakers.net/forum/list_message/45230302#45230302|here]] Power saving: * [[https://circuitdigest.com/microcontroller-projects/arduino-sleep-modes-and-how-to-use-them-to-reduce-power-consumption|Arduino sleep modes and how to use them to save the power]] * [[https://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/|Lightweight low power Arduino library]] * [[http://iot-bits.com/ultra-low-power-design-esp32-10-tips/|Ultra low power design with ESP32 – 10 ways to do it right]] ===== Sensors ===== * [[http://geektimes.ru/post/255118/|Датчики и микроконтроллеры: климат-контроль]] -- описывает датчики температуры, влажности, давления * [[youtube>hyKAB2-Ct-k|Сенсорный выключатель]] -- capacitive digital touch sensor / switch review {{https://i.postimg.cc/FsDdWBsN/vc1838b-pinout.jpg?200|IR infrared universal receiver TL1838 VS1838 pinout}} {{https://m.media-amazon.com/images/I/61tZIl-UIAL._AC_UF350,350_QL80_.jpg?200|SR602 motion detector pinout}} {{https://ae-pic-a1.aliexpress-media.com/kf/S9e2fb3021e6e4c9c97271f5366fa4966G.jpg_960x960q75.jpg_.avif?200|BME280 (humidity, pressure and temperature) vs BMP280 (pressure and temperature)}} ==== Vibration ==== * [[http://blog.sina.cn/dpool/blog/s/blog_624e2b450100olkw.html|SW-18010 circuit and program]] * [[http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/ky-002-arduino-vibration-shake-sensor-manual-and-tutorial/|KY-002 vibration shock sensor Arduino tutorial]] * [[https://www.luisllamas.es/medir-vibracion-con-arduino-y-sensor-sw-18020p/|Measure vibration with Arduino and sensor SW-18020P]] ==== Curtain ==== * [[https://sprut.ai/client/blog/654|Автоматизация рулонных штор]] * [[youtube>ocOO-8X_-Rk|DIY Motorized Roller Shades + Wireless MQTT Smart Home Integration]] * [[youtube>1O_1gUFumQM|Motorize and Automate your Blinds for $10]] * [[youtube>nrUu21NXrx0|Motorized Smart Curtains]] ==== Temperature ==== * [[https://randomnerdtutorials.com/9-arduino-compatible-temperature-sensors-for-your-electronics-projects/|9 Arduino compatible temperature sensors]] * [[http://wiki.seeedstudio.com/A_Comparison_of_Different_Grove_Temperature_Sensors/|A comparison of different grove temperature sensors]] The BME280 has more precise measurements but has its own problems too, as it suffers from self-heating in its default configuration (sampling data continuously). The library should switch the sensor into forced mode to make it sleep when the measurement is finished, see [[github>finitespace/BME280/issues/23#issuecomment-298332574|this comment]] and [[http://nilhcem.com/iot/home-monitoring-with-mqtt-influxdb-grafana|this post]]. ==== [[youtube>7j6DSND6Ass|Infrared thermograph / temperature sensor]] ==== Market price: [[aliexpress>33014745109|AMG8833 infrared thermal sensor – $51.83 (€47.90)]] DYI: * [[aliexpress>4000142029516|Infrared temperature sensor MLX90640-BAA – $56.98 (€52.97)]] * [[aliexpress>4000142029516|TTGO Backlight Adjustment PSARM 8M IP5306 I2C Development Board – $14.58 + $4.74 (€13.56 + €4.41)]] * [[aliexpress>32911391476|LiIon 3.7V 2000mAh size 5×3.4cm, built-in smart PCB charging module – $4.51 + $1.32 (€4.19 + €1.23)]] * Total: $82.13 ==== Climate control / CO₂ ==== * [[https://howtomechatronics.com/projects/diy-air-quality-monitor-pm2-5-co2-voc-ozone-temp-hum-arduino-meter/|DIY Air Quality Monitor – PM2.5, CO2, VOC, Ozone, Temperature & Humidity Arduino Meter]] ==== Oximeter / pulsometer ==== * [[youtube>oyeVw5IpknA|MAX30100 – сенсор для пульсоксиметрии]] * [[youtube>-IFwwWj11Kw|OLED-дисплей на контроллере SSD1306]] ==== Door bell ==== * [[youtube>BCjxcBOcyTo|Ultimate battery doorbell showdown 2022]] Measuring current: * [[https://3d-diy.ru/wiki/arduino-datchiki/datchik-toka-acs712/|Датчик тока ACS712: описание, подключение, схема, характеристики]], [[github>marianomd/acs712-esphome|ACS712 sensor component for esphome]] \\ [[https://electronics.stackexchange.com/a/487319/227889|Tuning current measuring for ACS712 interfaced with ESP8266]] \\ {{https://3d-diy.ru/upload/iblock/5e8/Datchik-toka-ACS712.jpg?300|Датчик тока ACS712}} * [[youtube>cG8moaufmQs&t=484|Measuring Current with Microcontrollers: 7 Sensors tested]] -- with resistors: MAX4080, INA169, INA219; with Hall sensors: ACS712, ACS758, WCS1800; Coulomb counter: LTC4150 * [[youtube>V0xHXOOq_vg|Кулонометр GC97. Доработка для интеграции с Blynk (и/или MQTT)]], [[youtube>2Jw_EfbDf2M|Кулонометр GC97 & Blynk. Пример скетча]] * [[https://diyi0t.com/ina219-tutorial-for-arduino-and-esp/|INA219 Tutorial for Arduino, ESP8266 and ESP32]] -- max 26V / 3A, I²C * [[http://arduino.ru/forum/obshchii/raschet-moshchnosti-rezistora-ili-pochemu-net-nagreva|Расчёт мощности резистора или почему нет нагрева?]] * [[aliexpress>32976366337|8 channel AC 220V channel optocoupler]] \\ {{https://ae01.alicdn.com/kf/HTB1QjyNdxTpK1RjSZR0q6zEwXXah.jpg?300|8 channel AC 220V channel optocoupler – $7.58}} * Схема детектора тока на оптопаре: \\ {{current_sensor.png?400}} В сумме резисторы определяют ток протекающий через светодиод. Чем он меньше, тем больше сопротивление перехода коллектор эмитер транзистора. Поскольку транзистор работает на высокоомный вход GPIO, то, думаю, конденсатор на 5-10 мкф + резистор подтяжки в пределах 10-20 кОм хватит. Наверно можно отойти от рекомендаций даташита и ограничить ток светодиодов парой милиампер (резисторы меньше греться будут) – тогда можно поставить два резистора в пределах 50 кОм. Для вычисления мощности резисторов берём закон Ома и считаем. Как на постоянном токе, считаем действующие значения тока и напряжения. 220В у нас падает на двух последовательных резисторах и диоде. Ну на диоде упасть больше 2В в принципе не может (как и меньше тоже) – им пренебрегаем – и считаем ток в цепи 220В/(50+50) кОм = 2.2 мА. Мощность рассеиваемая на резисторе считаем по формуле I×I×R = 2мА×2мА×50кОм=0.24 Вт плюс на втором резисторе ещё 0.24Вт, т.е всего рассеивается 0.48Вт чистым теплом. Поверьте это не мало. Один резистор в 100 кОм должен был бы рассеять почти 0.5Вт тепла. Хотя для варианта с детекцией дверного звонка этот кратковременный нагрев можно не считать проблемой. ====== Logical converter ====== [[https://learn.sparkfun.com/tutorials/bi-directional-logic-level-converter-hookup-guide/all|{{https://cdn.sparkfun.com/assets/parts/8/5/2/2/12009-07.jpg?300|Bi-Directional Logic Level Converter Hookup Guide}}]] [[https://electronics.stackexchange.com/questions/286518/5v-to-3-3v-logic-level-converter|{{https://i.stack.imgur.com/H1RJ2.png?500|5V to 3.3V bi-directional logic level converter}}]] [[https://electronics.stackexchange.com/questions/137801/im-building-a-3-3-to-5v-level-converter-with-a-mosfet-but-cant-reach-800khz|{{https://i.stack.imgur.com/P4oUq.png?500|Building a 3.3V to 5V level converter with a MOSFET}}]] * [[http://we.easyelectronics.ru/Shematech/soglasovanie-logicheskih-urovney-5v-i-33v-ustroystv.html|Согласование логических уровней 5В и 3.3В устройств ]] * [[https://electronics.stackexchange.com/questions/651513/how-does-a-logic-level-converter-with-a-n-channel-mosfet-work|How does a logic level converter with a N-channel MOSFET work?]] ====== USB-[[wp>Universal asynchronous receiver-transmitter|UART]] converter ====== {{https://3v3.com.ua/data/big/86149.jpg?250|Front}} {{https://ae01.alicdn.com/kf/HTB1fXifSXXXXXXHXVXXq6xXFXXXK.jpg?300|PCB}} {{https://image.easyeda.com/histories/35ded4137a354af3976788ff8adab71e.png?300|Schematic}} CH340E: * [[https://easyeda.com/dma_k/ch340e-uart|Schematic]] (cloned from [[https://easyeda.com/tedacy/ch340e-uart|here]]) * [[https://www.mpja.com/download/35227cpdata.pdf|Datasheet]], [[https://www.datasheet5.com/pdf-local-2195953|another]] CH340 supports 5V and 3.3V operation. When using 5V operation, supply 5V to VCC pin, and decouple the internal 3.3V reference with a capacitor of 4.7-20nF from V3 pin to ground. When using 3.3V operation, tie V3 pin to VCC pin and supply 3.3V power. ====== Controlling the power ====== === Using relay === * [[https://hackaday.com/2019/01/03/reset-your-router-the-modern-way/|Reset Your Router The Modern Way]] \\ {{https://hackaday.com/wp-content/uploads/2019/01/resetter-schematic.jpg}} See also: * [[https://qastack.ru/electronics/433122/is-there-a-kind-of-relay-that-consumes-power-only-when-switching|Есть ли реле, которое потребляет энергию только при переключении?]] * [[http://zametkielectrika.ru/sxema-podklyucheniya-i-princip-raboty-impulsnogo-rele-rio-1/|Схема подключения и принцип работы импульсного реле РИО-1]] * [[https://esphome.io/devices/sonoff_basic.html|Reflashing Sonoff Basic with ESPHome]] === Using MOSFET e.g. [[https://www.mouser.com/datasheet/2/196/irlb3034pbf-1732822.pdf|IRLB3034PbF]] === * Drain-to-Source Breakdown Voltage (V(BR)DSS): 40V * Gate Threshold Voltage (VGS(th): 1.0-2.5V * Static Drain-to-Source On-Resistance (RDS(on)): 1.6-2.0 mΩ * Рассеиваемая мощность при токе 5A: Pdis = 2mΩ × (5A)2 = 0.002Ω × 25A = 0.05W → температура корпуса транзистора будет RθJA × Pdis + Croom = 0.05W × 62°C/W + 25°C = 27.1°C See also: * [[https://3dtoday.ru/blogs/kraplax/the-choice-of-field-transistor-mosfet|Выбор полевого MOSFET транзистора для стола и экструдера]] * [[https://hubstub.ru/circuit-design/89-kak-vybrat-mosfet.html|Как выбрать MOSFET]] * [[https://elenergi.ru/top-5-mosfet-tranzistorov-s-minimalnym-soprotivleniem-stok-istok.html|Топ 5 MOSFET транзисторов с малым внутренним сопротивлением]] * [[https://electronics.stackexchange.com/questions/36098/selecting-a-mosfet-for-driving-load-from-logic|Selecting a MOSFET for driving load from logic]] * [[https://easyeda.com/kingtime13/2332131|Arduino + IRLB3034PbF example]] (via 100Ω resistor) === Using Solid State Relays (SSR) === [[aliexpress>32736680428|{{https://ae01.alicdn.com/kf/H2e26785b526f4b57ac0ccfe6c1a455d9U.jpg?300|G3MB-202P 5V SSR relay, 1 channel, 240VAC 2A – €1.55+€0.84=€2.59 ($3.08)}}]] [[https://www.ebay.com/itm/HFE60-5-1HDST-L2-Power-Relay-5A-250VAC-8-Pins-x-10pcs-/113590896229|{{https://i.ebayimg.com/images/g/0P0AAOSwna5cSGsu/s-l1600.jpg?300|HFE60-5-1HDST-L2 5V latching relay, 2 channel, 2 coils – $10+$8}}]] [[aliexpress>32581376219|{{https://ae01.alicdn.com/kf/H9f7a4c2af30b462894e40d97a752bcc6I/HFE60P-5-1HDST-5-1HDSTG-5-1HDST-L1-5-1HDST-L2-5-1HDST-R-5-2HST.jpg?300|HFE60P-5-1HDST-L2 5V latching relay, 2 channel, 2 coils}}]] [[aliexpress>4000960125832|{{https://ae01.alicdn.com/kf/H1bc0368930854e49b42eb51fc352498eR.jpg?300|HFD2-003-M-L2-D 3V latching relay, 2 channel, 2 coils, 220V 3A – €1.75 ($2.08)}}]] * [[https://www.macrogroup.ru/sites/default/files/uploads/catalog/Relay/Latching_relay/hfe60_en.pdf|HFE60-5-1HDST-L2 datasheet]] * [[https://pdf1.alldatasheet.com/datasheet-pdf/view/660902/HONGFA/HFD2/003-M-L2-D/+4W192WV.MMhhDdlKIvgYvEl/1M/1HPu+/datasheet.pdf|HFD2-003-M-L2-D datasheet]] See also: * [[https://elektrovesti.net/electricity/319_tverdotelnoe-rele-chto-eto-takoe-i-kak-ego-pravilno-ispolzovat|Твердотельное реле, что это такое и как его правильно использовать]] === Using dedicated controller + MOSFET === * [[https://serp1.ru/index/avtomaticheskij_perekljuchatel_pitanija/|Автоматический переключатель питания]] на микросхеме [[https://www.analog.com/media/en/dsp-documentation/evaluation-kit-manuals/DC1635afc.pdf|LTC4412]]. * [[https://www.rlocman.ru/shem/schematics.html?di=112476|Автоматическое переключение источников питания с помощью схемы на ОУ]] ===== Dimmer ===== * [[youtube>A-TI60oqiFA|Освещение по датчику движения. Качественный светодиодный диммер на Arduino (ATtiny13)]] ===== Other automations ===== * [[youtube>QcaJlpVOJ8U|Connect your pool to your smart home for $20 with Arduino]] * [[youtube>t2NgA8qYcFI|Upgrade Your Old Roomba to a Smart BotVac for $5]] * [[youtube>xCQoOZNdaGY|DIY Wireless Smart Doorbell for $11: Program ESP8266 NodeMCU with Arduino]] * [[youtube>BoYVr2UwWWg|$5 DIY Wireless MQTT Smart Home Window Sensors]] * [[youtube>OHANkpE7s4A|Hidden Features in the Ultimate $5 Smart Home Switch]] * [[youtube>1JrcQ0s55JU|$10 Remote Computer Power Management For Your Smart Home]] ====== FAQ ====== === [[https://arduino.stackexchange.com/a/51985/58657|Arduino Nano uploading gives error: avrdude: stk500_recv(): programmer is not responding]] === In Arduino UI choose ''Tools -> Processor -> ATmega328P (Old Bootloader)''. === [[https://arduino.stackexchange.com/a/67835/58657|Arduino Nano build-in LED conflicts with Ethernet shield]] === This is because the LED is on pin 13 and pin 13 is the clock pin for SPI device like Ethernet shield. === [[https://electronics.stackexchange.com/questions/545866/cannot-flash-wemos-d1-using-nodemcu|Alternative way to flash Wemos D1]] === [[youtube>zwp9E37ioVw&t=53|{{ https://i.ytimg.com/vi/zwp9E37ioVw/maxresdefault.jpg?300|Flash ESP-01 with your NodeMCU}}]] With NodeMCU: Connect the following pins between NodeMCU and Wemos D1: * RX → RX * TX → TX * D3 → D3 * RST → RST * 3.3V → 3.3V * GND → GND * EN → GND With [[https://easyeda.com/dma_k/ch340e-uart|USB-TTL converter]]: * RX → TX * TX → RX * 3.3V → 3.3V * GND → GND * D3 → GND (GPIO0 should be grounded when ESP is starting) === NodeMCU v3 (LoLin) built-in LED features === :WARN: LEDs operate in "inverted" mode, with regard to the pin levels -- when the pin is LOW, the LED is on. :WARN: Runnning ''pinMode(1, OUTPUT);'' breaks serial communication (when doing ''%%Serial.println("...");%%'' nothing is printed) because pin 1 and 3 are reserved for TX/RX. :WARN: [[https://arduino.stackexchange.com/a/38979/58657|Builtin LED on NodeMCU v3 (LoLin) is on D4 (pin 2)]] i.e. use ''pinMode(2, OUTPUT);''