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:

  • 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

Arduino

Arduino Nano pinout Arduino RF-Nano pinout ESP32 WeMos D1 mini NodeMCU V3 pinout NodeMCU V1 / V2 / V3 pinout ESP8266 models Wemos D1 mini versions

: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 LOLIN D1 mini description.

Name Price CPU CPU clock Flash SRAM Networking Power Interface PWM DAC
Arduino Nano v3.0 €3.60 + €0.92 = €4.52 ATmega328P 16Mhz 32KB 2KB :NO: shield costs €2.51 + €0.67 = €3.18 5..12V MiniUSB :YES: :YES:
LoLin NodeMCU V3 €1.89 + €0.88 = €2.77 ESP8266 80MHz 4MB 64KB :YES: built-in 2.4GHz WiFi 802.11 b/g/n 3.3..12V (e.g. 3.7V LiIon) MicroUSB :YES: :NO:
Wemos D1 mini V1 €1.76 + €0.66 = €2.42 ESP8266 80MHz 4MB 64KB :YES: built-in 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 €2.67 + €0.65 = €3.32 ESP8266 80MHz 16MB 128KB :YES: built-in 2.4GHz WiFi 802.11 b/g/n 3.3..12V (e.g. 3.7V LiIon) MicroUSB :YES: :NO:

Check:

Arduino clones need FTDI CH430 drivers from here (CH341SER.ZIP).

ESP

  • 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.

LED strips

Smart meter

Sensors

Vibration

Curtain

Temperature

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 this comment and this post.

Infrared thermograph / temperature sensor

Climate control / CO₂

Oximeter / pulsometer

Door bell

Measuring current:

  • Схема детектора тока на оптопаре:

    В сумме резисторы определяют ток протекающий через светодиод. Чем он меньше, тем больше сопротивление перехода коллектор эмитер транзистора. Поскольку транзистор работает на высокоомный вход 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

USB-UART converter

Front PCB Schematic

CH340E:

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

Using MOSFET e.g. 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:

Using Solid State Relays (SSR)

Using dedicated controller + MOSFET

Dimmer

Other automations

FAQ

Arduino Nano uploading gives error: avrdude: stk500_recv(): programmer is not responding

In Arduino UI choose Tools → Processor → ATmega328P (Old Bootloader).

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.

Alternative way to flash Wemos D1

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 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: Builtin LED on NodeMCU v3 (LoLin) is on D4 (pin 2) i.e. use pinMode(2, OUTPUT);

hardware/arduino.txt · Last modified: 2014/11/11 19:23 by dmitry
 
 
Recent changes RSS feed Driven by DokuWiki