JTK – Notes and Ramblings Things we have found …

12/30/2022

Shades – a start

Filed under: General,Home Automation — taing @ 12:21 pm

I decide to try the Home Depot Decorator Collection Shades. These have a motorize option that is controllable via Bluetooth using either their remote or a smartphone app (Android or iOS). The motor kit (FAQ) is pretty simple to install.

Unfortunately, there is no documented integration API. I found a few discussions online:

I am waiting to try the Bluetooth clone/copy MAC address scheme.

I did follow the shelly1 option as far as getting the required wires added. Simply add wires to the BTN (red wire on ribbon cable) and +W pins –

.

I have not yet completed the shelly1 connection or the integration into Openhab.

Yoda Speaks

Filed under: Arduino,General — taing @ 11:49 am

It was finally time to put the Sparkfun Papa Soundie to work. The Sparkfun hook-up guide provides most of the details – a 3.3v ATmega328P paired with the VLSI‘s VS1000D audio codec IC. They have created an Arduino library to control the VS1000D. This can be downloaded as a zip (archive version).

For the really adventurous there is VSIDE from VLSI to reprogram the firmware in the VS1000D – there are application examples, source code samples and additional PC tools available. We archived a copy of the VS1000D programmers guide.

I supplemented the Papa Soundie with a small speaker and a PIR motion sensor, Sparkfun’s OpenPIR. The sensor is based around the NCS36000 PIR controller and will work with 3v to 5.75v. Sparkfun has created a hook-up guide, also.

Audacity made quick work of converting a few .wav and .mp3 sound clips of Yoda’s voice to the preferred Ogg Vorbis / .ogg format. The preinstalled firmware on the VS1000D wants to find files in either .ogg or .wav format on the microSD card. The files should be named AUDIOxx.OGG or FILESxx.WAV (xx is 00 thru 31). Unfortunately, you need to start with 00 and not skip any slots.

I based my project on the Hardware Example Project from the Sparkfun Hook-up Guide. I removed the code for the servo and added code to prevent immediate re-triggering and to randomly select the file to play. The random selection is configured not to repeat a file until all have played – card deal style.

#include "SparkFun_PapaSoundie.h"

  int motionStatusOld = LOW;
  int motionStatus = LOW;
  int sounds[] = {1, 2, 3, 4, 5};
  int len = 5;

#define PIR_DOUT 9 

PapaSoundie sfx = PapaSoundie();

void setup() {
  Serial.begin(115200);  // Serial is used to view Analog out
  // Analog and digital pins should both be set as inputs (not actually necessary for Analog):
  pinMode(PIR_DOUT, INPUT);
  Serial.println("Getting ready");
  sfx.begin();
}

void loop() {
  int rnd;
  int choice;
  motionStatusOld = motionStatus;
  motionStatus = digitalRead(PIR_DOUT);
  if (motionStatus == HIGH && motionStatus != motionStatusOld) {
    if (len > 1) {
      rnd = random(len);
      choice = sounds[rnd];
      sounds[rnd] = sounds[len-1];
      len = len - 1;
    } else {
      choice = sounds[0];
      len = 5;
        for ( int i = 0; i < len; ++i ){
          sounds[i] = i+1;
        }      
    }
    
    Serial.println(choice);
    
    
    sfx.playFileNumber(choice);
    delay(1000);
  }
}

The wiring is very basic – 5vdc and ground in on the VIN and GND pins, 3.3vdc and ground out to the sensor from the 3.3v and GND pins and the output of the sensor to pin D9.

Keep in mind the sensor does require a bit of time after power-up before being active. The LED on the sensor PCB will blink slowly during start-up. Once up and running the LED will indicate motion.

I think the next step might be to add an LED. Possibly the Sparkfun RGB addressable thru hole version. This is a thru hole 8mm version of the typical WS2812. Three are details in their WS2812 Guide. Adafruit has a very nice Arduino library for the WS2812.

Sound activated Yoda

12/29/2022

Sonoff S31 and B1

Filed under: General,Home Automation — taing @ 9:47 pm

Sadly, I never posted any notes on the Sonoff products. Long ago I ordered a set of S31 outlets and B1 lamps. Both of which I reflashed with espurna. The notes on how to flash tasmota are helpful here, too. I found a quick tutorial on flashing with a Raspberry Pi in their docs. In todays world you might need to use pip3 instead of pip to install esptool. Tinkerman has posted lots of great details for the S31.

NEVER connect the S31 to mains power when flashing. For the S31 the connections to the Pi are very simpleSonoff S31 connections Raspberry Pi connections:

    S31 Pin - Pi Pin
    Vcc     - #1 (3.3vdc) - do not connect yet
    RX      - #8 (TX)
    TX      - #10 (RX)
    GND     - #39 (Ground)

Once you have the wiring ready you can setup the Pi – make sure you have esptool installed. If not sudo pip3 install esptool should handle it. You can then use raspi-config -> InterfaceOptions -> Serial to say No to shell on the serial port and Yes to Serial hardware.

The S31 will enter loader mode if you hold down the button, connect Vcc and continue holding the button for 10 seconds. You are now ready to actually flash the device(I was using an older Pi 2):

esptool.py --port /dev/ttyAMA0 erase_flash
esptool.py --port /dev/ttyAMA0 write_flash -fm dout 0x0 /path/to/downloaded/image

If you are using a Pi 3 or 4 replace ttyAMA0 with ttyS0.

The bad news is the Sonoff B1 is no longer made and their replacement uses a different chip and is not re-flashable. For the B1 lamps I have MQTT control after reflashing is awesome. MQTT make the integration with Openhab super easy. If you happen to come across these at a good price then the flashing instructions at the Tasmota site are very helpful.

Powered by WordPress