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 ...
|
||||
---
|
||||
|
||||
[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
|
||||
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:
|
||||
Turns out its not :D
|
||||
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**
|
||||
(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 ;)
|
||||
[^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
|
||||
|
@ -28,7 +28,7 @@ The transistor is marked red, as the photo is to potato-quality to make it out o
|
||||
| 4 | GPIO (LED)
|
||||
| 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
|
||||
light:
|
||||
- platform: monochromatic
|
||||
@ -76,12 +76,12 @@ switch:
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
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">}}
|
||||
|
@ -5,10 +5,10 @@ draft: false
|
||||
summary: Let the computer turn on the lamp...
|
||||
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.
|
||||
|
||||
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">}}
|
||||
|
||||
@ -55,14 +55,14 @@ web_server:
|
||||
logger:
|
||||
```
|
||||
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:
|
||||
```bash
|
||||
#/bin/sh!
|
||||
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!
|
||||
|
||||
|
@ -8,7 +8,7 @@ images:
|
||||
|
||||
**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...
|
||||
**YOU** get to read about it, too!
|
||||
|
@ -6,21 +6,21 @@ summary: "quick and dirty diy-christmas present(s)"
|
||||
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.
|
||||
Better for the enviroment 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 ;)
|
||||
This year for Christmas i set myself the challenge to not buy anything new to give away as presents.
|
||||
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 filament technically did lie around... not sure if that counts though ;)
|
||||
|
||||
|
||||
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.
|
||||
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 ;)
|
||||
|
||||
|
||||
[^1]: at least that is what i thought ;) ... My gf isn't realy 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
|
||||
[^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 really badly made); stl files are available also
|
||||
|
Loading…
x
Reference in New Issue
Block a user