• Schematic errors, first steps with the mainboard

    Christopha day ago 0 comments

    What I found so far:

    • Apparently I totally ignored the teensy's need for power. It does have a ground connection, BUT
    • Teensy's GND is connected to ESP'S Rx pin and
    • Teensy's Rx pin is unconnected

    I have some through hole schottky diodes so I'll put one between 5V and the Teensy's 5V pin, so that the Teensy can be powered via USB or an external supply. All that was needed was some magnet wire and the diode:

    That seems to work. Top view:

    The Teensy is currently running a crude serial passthrough sketch so that I can use it to

    • program the ESP or
    • debug the ESP application via serial

    This is the crude serial passthrough sketch:

    void setup() {
      // put your setup code here, to run once:
      Serial1.begin(115200);
      Serial.begin(115200);
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      if(Serial.available())
      {
        Serial1.write(Serial.read());
      }
      if(Serial1.available())
      {
        Serial.write(Serial1.read());
      }
    }

    The ESP app already connects to my WiFi using config data stored in the FFS and I'll now extend it to subscribe to MQTT topics as described in the previous log.

  • Node-red flow, ESP and Teensy considerations

    Christoph3 days ago 0 comments

    The lamp will subscribe to three MQTT topics:

    • lack_lamp/time : time in HH:mm format, updated each minute. This message is not retained because it won't really matter if the first time update is done when the lamp becomes online, or if it's one minute later.
    • lack_lamp/top: brightness level for the top LEDs, 0...100, retained. If a brightness level is set, the lamp shall go straight to that when it comes online.
    • lack_lamp/bottom: brightness level for the bottom LEDs (the small, vertically moving lamps); 0...100, retained.

    Flow screenshot:

    Flow code:

    [{"id":"aa4bc419.8a1788","type":"tab","label":"lack clock","disabled":false,"info":""},{"id":"4e9f9b17.5f2734","type":"inject","z":"aa4bc419.8a1788","name":"","topic":"lack_lamp/time","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":120,"wires":[["5653f91e.a05548"]]},{"id":"600a5141.5a463","type":"ui_slider","z":"aa4bc419.8a1788","name":"","label":"brightness top","tooltip":"","group":"95d92d08.7ad69","order":0,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"100","step":1,"x":220,"y":220,"wires":[["2c8d835f.7c011c"]]},{"id":"25cdf3b3.c8379c","type":"ui_slider","z":"aa4bc419.8a1788","name":"","label":"brightness bottom","tooltip":"","group":"95d92d08.7ad69","order":0,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"100","step":1,"x":210,"y":280,"wires":[["3337ab02.51efe4"]]},{"id":"3f3f2d01.17e1a2","type":"mqtt out","z":"aa4bc419.8a1788","name":"","topic":"lack_lamp/time","qos":"0","retain":"false","broker":"1b428099.712eff","x":680,"y":120,"wires":[]},{"id":"5653f91e.a05548","type":"moment","z":"aa4bc419.8a1788","name":"","topic":"","input":"","inputType":"msg","inTz":"Europe/London","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm","locale":"de_DE","output":"","outputType":"msg","outTz":"Europe/London","x":440,"y":120,"wires":[["3f3f2d01.17e1a2"]]},{"id":"2c8d835f.7c011c","type":"mqtt out","z":"aa4bc419.8a1788","name":"","topic":"lack_lamp/top","qos":"0","retain":"true","broker":"1b428099.712eff","x":480,"y":220,"wires":[]},{"id":"3337ab02.51efe4","type":"mqtt out","z":"aa4bc419.8a1788","name":"","topic":"lack_lamp/bottom","qos":"0","retain":"true","broker":"1b428099.712eff","x":490,"y":280,"wires":[]},{"id":"95d92d08.7ad69","type":"ui_group","z":"","name":"Lack Lamp","tab":"921e5f7.58b2da","disp":true,"width":"6","collapse":false},{"id":"1b428099.712eff","type":"mqtt-broker","z":"","name":"piffi","broker":"piffi","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"921e5f7.58b2da","type":"ui_tab","z":"","name":"Lack Lamp","icon":"dashboard","disabled":false,"hidden":false}]

    Now everything the ESP needs to do is get into my WiFi, subscribe to the three topics, and dump messages to the serial interface when something happens. These will need some sort of prefix to tell them apart, because time and the two brightness values usually won't be updated at the same time. When one of the brightness values changes, I want it to be updated immediately and not when the next time update occurs. On the other hand, time will probably be the variable that is updated most frequently.

    Prefixes will be "t" for time, "T" for top brightness and "B" for bottom:

    t 07:42
    T 45
    B 0

    This will be easy to generate on the ESP and easy to parse on the Teensy.

    The Teensy has to 

    • parse these messages
    • move servos based on time
    • adjust brightness for top and bottom LEDs

    Having both servos via PPM and PWM brightness adjustments makes things slightly more complicated on the Teensy. Both PPM and PWM use a timer, so output pins must be chosen such that the timer outputs don't interfere with each other (see https://www.pjrc.com/teensy/td_pulse.html). So I have

    • all PPM timer outputs on FTM0 (outputs 5,6,9)
    • all...
    Read more »

  • First bits are ready for a test

    Christoph5 days ago 0 comments

    Small Lamps

    I use a piece of paracord (without the core) to hang the small lamps from the main lamp. 9 LEDs (7.5 cm of 120 LED/m strip) emit light and need about 65 mA at 12 V. This can be supplied by 0.35 mm magnet wire without problem. However, they are so lightweight that even the magnet wire won't be straight so I need to add a stiffener to the hollow paracord. For a first test, I used a toothpick as stiffener.

    Assembly starts with a small tapered 3d printed part glued to the stiffener:

    This part and the magnet wires are inserted into the paracord, and into the shade's centerpiece:

    The LEDs are stuck to a ring which is glued to the centerpiece. Here's the whole thing assembled:

    Now we can clip on a little "dress" from below, so the little lamps can be re-dressed as desired:

    I might print the parts again in transparent filament to have some light exit through the top.

    Now the stiffener straightens the paracord, but ends somewhere along the way because the upper part of the paracord needs to bend around a disk rotated by a servo. That's how I can make the lamps move vertically without any sideways movement:

    Since the print is so glossy, here's a view from OpenSCAD:

    The rectangular pockets can be used to clamp the paracord to the wheel with a piece of perfboard and two M2 screws.

    The servos are driven by a Teensy 3.2 which uses the PulsePosition library to generate PPM that is fed into a shift register (one shift reg for 8 servos). I need 12 small lamps, so two of these boards:

    The Teensy will receive commands from an ESP-01 over serial. The ESP will receive over MQTT from a server which is running on a local RPi anyway. More on that later.

    I'm currently trying to figure out which kind of stiffener I want to use that is easy to use, more or less straight, and cheap.