spellcheck enabled in vim ;)
This commit is contained in:
parent
649f2276cf
commit
dbd3c757eb
@ -5,19 +5,19 @@ draft: false
|
|||||||
summary: i wanted to know what all that fuss is about so i fianlly put micropython on the ESP32 ...
|
summary: i wanted to know what all that fuss is about so i fianlly put micropython on the ESP32 ...
|
||||||
---
|
---
|
||||||
|
|
||||||
[micropython](https://micropython.org/) is python for microcontrollers. When i first heard about it i wasnt realy sure what to think about it as python is a realy high level language and now that should run on a microcontroller ? no way, that has to be a slow mess...
|
[micropython](https://micropython.org/) is python for microcontroller. When i first heard about it i wasn't really sure what to think about it as python is a really high level language and now that should run on a microcontroller ? no way, that has to be a slow mess...
|
||||||
|
|
||||||
turns out its not :D
|
Turns out its not :D
|
||||||
I mean it is, but for most of (my) projects you realy don't need the speed anyways. Also the prog-mem of the ESP32 is so big it doesn't realy matter that more than one quarter of it is now occupied with code that doesn't do anything at first. Now that i covered the bad sides of uPython i'll tell you about the realy big strengths and advantages it has over c and c++ for microcontroller programming:
|
I mean it is, but for most of (my) projects you really don't need the speed anyways. Also the prog-mem of the ESP32 is so big it doesn't really matter that more than one quarter of it is now occupied with code that doesn't do anything at first. Now that i covered the bad sides of uPython i'll tell you about the really big strengths and advantages it has over c and c++ for microcontroller programming:
|
||||||
|
|
||||||
**Read–eval–print loop**
|
**Read–eval–print loop**
|
||||||
(or REPL for short)
|
(or REPL for short)
|
||||||
|
|
||||||
with that you get an interactive console (with tab-autocompletion!) over the serial port and you can prototype without ever needing to wait hours and hours[^1] for code to compile and upload. And you can focus on the electronic and not on some stupid dependency error. Its just like you know it from pythons console with a (somtimes annoying) difference: you only get to press the up arror 7 times[^2] to get previouly typed commands as the history is saved on the uC itself. Not sure why thats done that way, i would have saved the history in the REPL calling device (but maybe im missing somethin)... so maybe i'll make a PR if its bothering me enough, even if i never have written any Javascript in my life before ;)
|
With that you get an interactive console (with tab-autocompletion!) over the serial port and you can prototype without ever needing to wait hours and hours[^1] for code to compile and upload. And you can focus on the electronic and not on some stupid dependency error. Its just like you know it from pythons console with a (sometimes annoying) difference: you only get to press the up arrow 7 times[^2] to get previously typed commands as the history is saved on the uC itself. Not sure why that's done that way, i would have saved the history in the REPL calling device (but maybe im missing something)... so maybe i'll make a PR if its bothering me enough, even if i never have written any Javascript in my life before ;)
|
||||||
|
|
||||||
This is a short post but maybe i could inspire you to try out micropython on your own in the future if you havent already.
|
This is a short post but maybe i could inspire you to try out micropython on your own in the future if you haven't already.
|
||||||
|
|
||||||
The projects im currently working on are some christmas presents (involving a uC with micropython, obviously) so stay tunes for that.
|
The projects im currently working on are some Christmas presents (involving a uC with micropython, obviously) so stay tunes for that.
|
||||||
|
|
||||||
[^1]: it's minutes at max most of the time, but still ;)
|
[^1]: it's minutes at max most of the time, but still ;)
|
||||||
[^2]: i think its changable but the downloadable uPython binary has 7 as a default
|
[^2]: i think its changeable but the downloadable uPython binary has 7 as a default
|
||||||
|
@ -5,7 +5,7 @@ draft: false
|
|||||||
summary: Adding buttons to my "smart desk"
|
summary: Adding buttons to my "smart desk"
|
||||||
images: [/static/img/buttons-anim.gif, /static/img/buttons-aus.jpg, /static/img/buttons-switches-marked.jpg]
|
images: [/static/img/buttons-anim.gif, /static/img/buttons-aus.jpg, /static/img/buttons-switches-marked.jpg]
|
||||||
---
|
---
|
||||||
Last [post]({{< ref "/posts/desk-automation.md" >}}) i teased the next upgrade of my smart desk project which are some big arcade buttons to control the light even when my network is down. Well...
|
Last [post]({{< ref "/posts/desk-automation.md" >}}) i teased the next upgrade of my smart desk project which are some big arcade buttons to control the light even when my network is down. Well...
|
||||||
|
|
||||||
I finished that part over the last few days:
|
I finished that part over the last few days:
|
||||||
|
|
||||||
@ -13,22 +13,22 @@ I finished that part over the last few days:
|
|||||||
|
|
||||||
The buttons i did choose for the desk are thous big arcade buttons[^1] as they produce this satisfying click when pressed. They come with an integrated LED and resistor, but -as they are not supposed to be driven by a 3.3 volt microcontroller- they need 12 volt supplied to be fully lit up. For the controller i use a normal USB power supply so i tried to power the LEDs with 5 volts. That made them bright enough so i went with that...
|
The buttons i did choose for the desk are thous big arcade buttons[^1] as they produce this satisfying click when pressed. They come with an integrated LED and resistor, but -as they are not supposed to be driven by a 3.3 volt microcontroller- they need 12 volt supplied to be fully lit up. For the controller i use a normal USB power supply so i tried to power the LEDs with 5 volts. That made them bright enough so i went with that...
|
||||||
|
|
||||||
The button comes in 2 parts which have to be assembled together. The first part is the thing you actually press (which also lets the light pass) and the second part is the Switch+LED combo. To make a neat package i modified the second part. By modified i mean i soldered a transistor to the pins to up the 3.3V logic level from the GPIOs of the controller to 5V needed for the LED. For that i just used a normal 2N2222 NPN-Transistor[^2].
|
The button comes in 2 parts which have to be assembled together. The first part is the thing you actually press (which also lets the light pass) and the second part is the Switch+LED combo. To make a neat package i modified the second part. By modified i mean i soldered a transistor to the pins to up the 3.3V logic level from the GPIOs of the controller to 5V needed for the LED. For that i just used a normal 2N2222 NPN-Transistor[^2].
|
||||||
|
|
||||||
Soldered together the switches + transistor + some cables the "thing" looks something like this:
|
Soldered together the switches + transistor + some cables the "thing" looks something like this:
|
||||||
{{< figure src="/img/buttons-switches-marked.jpg">}}
|
{{< figure src="/img/buttons-switches-marked.jpg">}}
|
||||||
|
|
||||||
The transistor is marked red, as the photo is to potato-quality to make it out otherwise :D
|
The transistor is marked red, as the photo is to potato-quality to make it out otherwise :D
|
||||||
|
|
||||||
| pin | connected to
|
| pin | connected to
|
||||||
| -----------|------
|
| -----------|------
|
||||||
| 1 | GPIO (Switch)
|
| 1 | GPIO (Switch)
|
||||||
| 2 | 3.3V
|
| 2 | 3.3V
|
||||||
| 3 | 5V
|
| 3 | 5V
|
||||||
| 4 | GPIO (LED)
|
| 4 | GPIO (LED)
|
||||||
| 5 | GND
|
| 5 | GND
|
||||||
|
|
||||||
after hooking it up the the controller i had to change and add some parts of the configuration yaml of the esphome-firmware:
|
After hooking it up to the controller i had to change and add some parts of the configuration YAML of the esphome-firmware:
|
||||||
```yaml
|
```yaml
|
||||||
light:
|
light:
|
||||||
- platform: monochromatic
|
- platform: monochromatic
|
||||||
@ -43,7 +43,7 @@ output:
|
|||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
pin:
|
pin:
|
||||||
number: 12
|
number: 12
|
||||||
inverted: True
|
inverted: True
|
||||||
mode: INPUT_PULLUP
|
mode: INPUT_PULLUP
|
||||||
@ -65,27 +65,27 @@ switch:
|
|||||||
id: relay1
|
id: relay1
|
||||||
on_turn_on:
|
on_turn_on:
|
||||||
then:
|
then:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: rotled
|
id: rotled
|
||||||
transition_length: 200ms
|
transition_length: 200ms
|
||||||
on_turn_off:
|
on_turn_off:
|
||||||
then:
|
then:
|
||||||
- light.turn_off:
|
- light.turn_off:
|
||||||
id: rotled
|
id: rotled
|
||||||
transition_length: 500ms
|
transition_length: 500ms
|
||||||
```
|
```
|
||||||
|
|
||||||
The added parts in the on\_turn\_{on,off} sections of the switch turn the LED {on,off}.
|
The added parts in the on\_turn\_{on,off} sections of the switch turn the LED {on,off}.
|
||||||
By hooking them up to the switch activation and not the button press the leds also turn on when the relay gets activated via the webserver.
|
By hooking them up to the switch activation and not the button press the LEDs also turn on when the relay gets activated via the webserver.
|
||||||
The "transition_length: ...ms" parameter makes the LED fade in and out smoothly (only works on an PWM GPIO).
|
The "transition_length: ...ms" parameter makes the LED fade in and out smoothly (only works on an PWM GPIO).
|
||||||
|
|
||||||
After that there only was a case to design and 3D print. I settled for the classic highly complex[^3] box shape design as you can see in the image above.
|
After that there only was a case to design and 3D print. I settled for the classic highly complex[^3] box shape design as you can see in the image above.
|
||||||
|
|
||||||
As you can see in the image i have another blue button next the the red one... not realy sure what to do with it right now, if i come up with something i'll probably do another post about it here ;)
|
As you can see in the image i have another blue button next to the red one... not really sure what to do with it right now, if i come up with something i will probably do another post about it here ;)
|
||||||
|
|
||||||
|
|
||||||
{{< figure src="/img/buttons-anim.gif">}}
|
{{< figure src="/img/buttons-anim.gif">}}
|
||||||
|
|
||||||
[^1]: You can find them easily when you search ebay or any other site that sells electronics from china
|
[^1]: You can find them easily when you search ebay or any other site that sells electronics from china
|
||||||
[^2]: [Sparkfun](https://learn.sparkfun.com/tutorials/transistors/applications-i-switches) describes the basic circuit quite good
|
[^2]: [Sparkfun](https://learn.sparkfun.com/tutorials/transistors/applications-i-switches) describes the basic circuit quite good
|
||||||
[^3]: "super complex"
|
[^3]: "super complex"
|
||||||
|
@ -5,10 +5,10 @@ draft: false
|
|||||||
summary: Let the computer turn on the lamp...
|
summary: Let the computer turn on the lamp...
|
||||||
images: [/static/img/lamp-relay-esp.png]
|
images: [/static/img/lamp-relay-esp.png]
|
||||||
---
|
---
|
||||||
Automation makes the life easier. At least thats what it should do...
|
Automation makes the life easier. At least that's what it should do...
|
||||||
In my case im not sure it actually did simplify my life as a few years later i own way more stuff and tools to build said automation than my small dorm room can handle.
|
In my case im not sure it actually did simplify my life as a few years later i own way more stuff and tools to build said automation than my small dorm room can handle.
|
||||||
|
|
||||||
Most of the stuff i build is now living on my desk. Among other things that includes my "smart" desk lamp[^1], which is just a normal IKEA lamp[^2] with the power cord cut, a 2-Channel relay from ebay and an ESP32 (which is a microcontroler with WIFI). Thous things in combination allow me to turn the lamp on when its getting dark and off when i'm finally lying in bed, which would normally be way out of reach of the light switch.
|
Most of the stuff i build is now living on my desk. Among other things that includes my "smart" desk lamp[^1], which is just a normal IKEA lamp[^2] with the power cord cut, a 2-Channel relay from ebay and an ESP32 (which is a microcontroller with WIFI). Thous things in combination allow me to turn the lamp on when its getting dark and off when i'm finally lying in bed, which would normally be way out of reach of the light switch.
|
||||||
|
|
||||||
{{< figure src="/img/lamp-relay-esp.png" title="Relay wiring">}}
|
{{< figure src="/img/lamp-relay-esp.png" title="Relay wiring">}}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ ota:
|
|||||||
|
|
||||||
switch:
|
switch:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
pin:
|
pin:
|
||||||
number: 33
|
number: 33
|
||||||
inverted: True
|
inverted: True
|
||||||
name: "Schreibtischlampe"
|
name: "Schreibtischlampe"
|
||||||
@ -55,14 +55,14 @@ web_server:
|
|||||||
logger:
|
logger:
|
||||||
```
|
```
|
||||||
After the first flashing of the ESP you can update the firmware over the air which is quite nice.
|
After the first flashing of the ESP you can update the firmware over the air which is quite nice.
|
||||||
As you can see i defined a webserver which enables a REST-Api on the device.
|
As you can see i defined a webserver which enables a REST-API on the device.
|
||||||
To turn on the lamp on/off i can just type call a easy script which uses curl to make the request:
|
To turn on the lamp on/off i can just type call a easy script which uses curl to make the request:
|
||||||
```bash
|
```bash
|
||||||
#/bin/sh!
|
#/bin/sh!
|
||||||
curl -u <usr>:<pw> -X POST http://192.168.222.20/switch/schreibtischlampe/toggle
|
curl -u <usr>:<pw> -X POST http://192.168.222.20/switch/schreibtischlampe/toggle
|
||||||
```
|
```
|
||||||
|
|
||||||
This setup already works but its actually not that good to only be able to control the lamp via a network connection. If thats down i can't turn on the light to fix[^3] the network connection which is bad cause then i cant turn on the light...
|
This setup already works but its actually not that good to only be able to control the lamp via a network connection. If that's down i can't turn on the light to fix[^3] the network connection which is bad cause then i cant turn on the light...
|
||||||
|
|
||||||
To escape that vicious circle of darkness i plan to add some nice tactile arcade buttons to my desk. Stay tuned for that!
|
To escape that vicious circle of darkness i plan to add some nice tactile arcade buttons to my desk. Stay tuned for that!
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@ images:
|
|||||||
|
|
||||||
**Documentation is the most boring part of any project. However that doesn't mean its not important...**
|
**Documentation is the most boring part of any project. However that doesn't mean its not important...**
|
||||||
|
|
||||||
Everything requieres mantainance and so there will come the day when you have to open up the project[^1] again and fix or repair something. For me this is always exiting since most of the time i have completely forgotten most of what i have done to do the repair. Having to sit down and getting into the mindset of my past self by just looking at the internals of the project takes way more time then if i just had written a few words about the thing in the first place.
|
Everything requires maintenance and so there will come the day when you have to open up the project[^1] again and fix or repair something. For me this is always exiting since most of the time i have completely forgotten most of what i have done to do the repair. Having to sit down and getting into the mindset of my past self by just looking at the internals of the project takes way more time then if i just had written a few words about the thing in the first place.
|
||||||
|
|
||||||
That is where this blog comes into play. I want to have a fun way of just writing some quick words about a project while working on it. That way i can freshen up my memories when i need to know the details again. And there is a side benefit to that...
|
That is where this blog comes into play. I want to have a fun way of just writing some quick words about a project while working on it. That way i can freshen up my memories when i need to know the details again. And there is a side benefit to that...
|
||||||
**YOU** get to read about it, too!
|
**YOU** get to read about it, too!
|
||||||
|
|
||||||
Let's see how that pans out or if im just going to stop after the first view posts ;)
|
Let's see how that pans out or if im just going to stop after the first view posts ;)
|
||||||
|
|
||||||
[^1]: be it software or hardware
|
[^1]: be it software or hardware
|
||||||
|
@ -6,21 +6,21 @@ summary: "quick and dirty diy-christmas present(s)"
|
|||||||
images: ["/static/img/led-cricle-rainbow.png"]
|
images: ["/static/img/led-cricle-rainbow.png"]
|
||||||
---
|
---
|
||||||
|
|
||||||
This year for christmas i set myself the challange to not buy anything new to give away as presents.
|
This year for Christmas i set myself the challenge to not buy anything new to give away as presents.
|
||||||
Better for the enviroment and forces me to get creative[^1] with the stuff i already have lying around.
|
Better for the environment and forces me to get creative[^1] with the stuff i already have lying around.
|
||||||
I ended up designing something with my 3D-Printer. The fillament techincaly did lie around... not sure if that counts though ;)
|
I ended up designing something with my 3D-Printer. The filament technically did lie around... not sure if that counts though ;)
|
||||||
|
|
||||||
|
|
||||||
Anyways, this is what i came up with:
|
Anyways, this is what i came up with:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
It's a 3D-Printed enclosure with some paper glued to as a diffuser for 32 RGB-LEDs. The brains is an ESP32 running micropython (which i praised in my last [post]({{< ref "/posts/dabbling-micropython.md" >}})).
|
It's a 3D-Printed enclosure with some paper glued to as a diffuser for 23 RGB-LEDs. The brains is an ESP32 running micropython (which i praised in my last [post]({{< ref "/posts/dabbling-micropython.md" >}})).
|
||||||
Right now it just plays 2 "animations" which you can switch between with a button on the bottom side of the case. A second button changes the brightness.
|
Right now it just plays 2 "animations" which you can switch between with a button on the bottom side of the case. A second button changes the brightness.
|
||||||
That's all for the functionality at the moment. *BUT* when there is the inevitable break between meals on christmas i plan to create some more nice animations and try to expose a REST-Interface to be able to change animation and brighntess over the network.
|
That's all for the functionality at the moment. *BUT* when there is the inevitable break between meals on Christmas i plan to create some more nice animations and try to expose a REST-Interface to be able to change animation and brightness over the network.
|
||||||
|
|
||||||
I put the design files[^2], the code and some basic instructions on [github](https://github.com/schnilz/led-circle). So feel free to make your own or suggest some changes ;)
|
I put the design files[^2], the code and some basic instructions on [github](https://github.com/schnilz/led-circle). So feel free to make your own or suggest some changes ;)
|
||||||
|
|
||||||
|
|
||||||
[^1]: at least that is what i thought ;) ... My gf isn't realy impressed with RGB-LEDs anymore ^^
|
[^1]: at least that is what i thought ;) ... My gf isn't really impressed with RGB-LEDs anymore ^^
|
||||||
[^2]: all created with FreeCAD <3 (im still learning that software so the design is probably realy badly made); stl files are available also
|
[^2]: all created with FreeCAD <3 (im still learning that software so the design is probably really badly made); stl files are available also
|
||||||
|
Loading…
x
Reference in New Issue
Block a user