Patriks hemsida https://patrikhermansson.se/index.php/rss.xml en Program Esp01 with a Raspberry Pi https://patrikhermansson.se/index.php/node/524 <span class="field field--name-title field--type-string field--label-hidden">Program Esp01 with a Raspberry Pi</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/user/1" typeof="schema:Person" property="schema:name" datatype="">patrik</span></span> <span class="field field--name-created field--type-created field--label-hidden">Sat, 2016-12-17 10:39</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Connect module as in http://www.esp8266.com/wiki/doku.php?id=raspberrypi:getting_started</p> <p>sudo apt install picocom</p> <p>sudo systemctl stop serial-getty@ttyS0.service<br /> sudo systemctl disable serial-getty@ttyS0.service</p> <p>sudo nano /boot/config.txt<br /> Add enable_uart=1</p> <p>sudo nano /boot/cmdline.txt<br /> Remove console=serial0,115200 </p> <p>sudo apt-get install git-core<br /> git clone git://git.drogon.net/wiringPi</p> <p>cd wiringPi<br /> ./build</p> </div>Sat, 17 Dec 2016 08:39:33 +0000patrik524 at https://patrikhermansson.sehttps://patrikhermansson.se/index.php/node/524#comments Remote on for Raspberry Pi https://patrikhermansson.se/index.php/node/523 <span class="field field--name-title field--type-string field--label-hidden">Remote on for Raspberry Pi</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/user/1" typeof="schema:Person" property="schema:name" datatype="">patrik</span></span> <span class="field field--name-created field--type-created field--label-hidden">Sat, 2016-12-10 17:34</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>This project is about to add a remote power on "switch" to a Raspberry Pi.<br /> To switch the Pi on I use the connector "Run" on the board. If the two connections are shorted the Raspberry will power up. The plan is to use a BC547 transistor to short the pins. A ESP01 Wifi uC will control the transistor, make it conduct when a certain Mqtt-message has arrived. </p> <p>The first step is to connect the ESP01 to a computer and program it with the "Arduino OTA/BasicOTA" sketch from Examples. This makes it possible to program the Esp via Wifi. The only change in the code for now is the ssid in line 6 that I set to the name of my Wifi.<br /> I also temporarily connect a switch between Gnd and Gpio0 and a small wire between Ch_pd and Vcc and use a USB-ESP01-adapter (<a href="http://www.ebay.com/itm/1PCS-ESP01-Programmer-Adapter-UART-GPIO0-ESP-01-Adaptateur-ESP8266-USB-NEW-/222121082897?hash=item33b772c011:g:BVMAAOSwB9xXOuiG">see here</a>) to connect to the computer.<br /> The switch is pressed and the device is connected to the computer, then I release the switch and upload the sketch from the Arduno IDE. Then the device is disconnected and connected again. After a short while there will be a new network port in Arduino IDE:s Port menu. This is then used for further programming.</p> </div>Sat, 10 Dec 2016 15:34:18 +0000patrik523 at https://patrikhermansson.sehttps://patrikhermansson.se/index.php/node/523#comments ESP-01 "Al Cloud inside" https://patrikhermansson.se/index.php/node/522 <span class="field field--name-title field--type-string field--label-hidden">ESP-01 &quot;Al Cloud inside&quot;</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/user/1" typeof="schema:Person" property="schema:name" datatype="">patrik</span></span> <span class="field field--name-created field--type-created field--label-hidden">Thu, 2016-09-22 10:56</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Bought some new ESP-01:s, the version with the black board labeled "Al cloud inside" (<a href="http://www.ebay.com/itm/172228831941?_trksid=p2057872.m2749.l2649&amp;ssPageName=STRK%3AMEBIDX%3AIT">here</a>. At first I tried to talk to it via Arduinos serial monitor, connected the Esp via a USB-adapter (<a href="http://www.ebay.com/itm/331860642832?_trksid=p2057872.m2749.l2649&amp;ssPageName=STRK%3AMEBIDX%3AIT">here</a>). </p> <p>Tried some different settings in the serial monitor, what worked was 115200 baud, both NL &amp; CR:</p> <p><code><br /> AT+CSYSHEAP</code></p> <p>+CSYSHEAP:25280Bytes</p> <p>OK</p> <p>AT+GMR</p> <p>AT version:0.60.0.0(Jan 29 2016 15:10:17)<br /> SDK version:1.5.2(7eee54f4)<br /> Ai-Thinker Technology Co. Ltd.<br /> May 5 2016 17:30:30<br /> OK</p> <p></p> <p>With an Android phones network settings we find that the Esp has started a network named Ai-thinker_c2c338.<br /> The app Fing tells that the Esp:s Ip is 192.168.4.1.</p> </div>Thu, 22 Sep 2016 07:56:20 +0000patrik522 at https://patrikhermansson.sehttps://patrikhermansson.se/index.php/node/522#comments ESP01 as wireless programmer https://patrikhermansson.se/index.php/node/521 <span class="field field--name-title field--type-string field--label-hidden">ESP01 as wireless programmer</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/user/1" typeof="schema:Person" property="schema:name" datatype="">patrik</span></span> <span class="field field--name-created field--type-created field--label-hidden">Tue, 2016-08-02 16:04</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Here we use a ESP-01 to program a Arduino.<br /> The base is the Esp-link project, <a href="https://github.com/jeelabs/esp-link">https://github.com/jeelabs/esp-link</a>.<br /> I use a ESP-01 and connect it like this:<br /> URXD: connect to TX of microcontroller<br /> UTXD: connect to RX of microcontroller<br /> GPIO0: connect to RESET of microcontroller</p> <p>When using a 5V Arduino I use a resistor divider on the ESP:s RX as it's not 5 volt tolerant. 20k from Esp:s RX to ground, 10k to Arduino:s TX. No divider is needed on the ESP:s TX as it is an output.<br /> The firmware for the ESP is at <a href="https://github.com/jeelabs/esp-link/releases">https://github.com/jeelabs/esp-link/releases</a>, there we also find how to upload it to the ESP: </p> <p>curl -L https://github.com/jeelabs/esp-link/releases/download/v2.2.3/esp-link-v2.2.3.tgz | \<br /> tar xzf -<br /> cd esp-link-v2.2.3<br /> esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash -fs 4m -ff 40m \<br /> 0x00000 boot_v1.5.bin 0x1000 user1.bin 0x7E000 blank.bin</p> <p>For a newer module (has a black circuit board) I use this:<br /> esptool.py --port /dev/ttyUSB1 --baud 460800 write_flash -fs 8m -ff 40m 0x00000 boot_v1.5.bin 0x1000 user1.bin 0xFE000 blank.bin</p> <p>We then find the settings for the ESP in the web browser on its IP-address, which is found by the Android-app Fing (or the serial port?).<br /> First I use the Androids network settings to connect to the Esp:s network (named ESP-xxxx).<br /> Then I use the Androids web browser to open 192.168.4.1, here we find the Esplink gui. </p> <p>Here we set the following:<br /> Reset Gpio0<br /> ISP disabled<br /> Conn LED disabled<br /> Serial led gpio2 (optional)<br /> Uart pins Normal<br /> RX pull-up not selected.</p> <p>Also change baud rate to 57600 on the uC Console page.</p> <p>Compile the code in the Arduino IDE. A hex-file is then placed in /tmp. Here I compiled the sketch "lawnmower2016.ino" and got this hex-file:<br /> "tmp/builde2680df248d7f8adec6f6bb45c90d9b2.tmp/lawnmower2016.ino.hex"</p> <p>Then upload the Arduino code:</p> <p>avrdude -C/home/patrik/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino2/etc/avrdude.conf -v -patmega328p -carduino -P net:192.168.1.130:23 -b57600 -D -Uflash:w:/tmp/buildc32c2ad5c4b48bdb68bb9d08401b0d31.tmp/Blink.ino.hex:i </p> <p>Another one:<br /> avrdude -C/home/patrik/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino2/etc/avrdude.conf -v -patmega328p -carduino -P net:192.168.1.130:23 -b57600 -D -Uflash:w:/tmp/builde2680df248d7f8adec6f6bb45c90d9b2.tmp/lawnmower2016.ino.hex:i</p> </div>Tue, 02 Aug 2016 13:04:45 +0000patrik521 at https://patrikhermansson.sehttps://patrikhermansson.se/index.php/node/521#comments Stiga Autoclip 140 / Ambrogio L50 https://patrikhermansson.se/index.php/node/519 <span class="field field--name-title field--type-string field--label-hidden">Stiga Autoclip 140 / Ambrogio L50</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/user/1" typeof="schema:Person" property="schema:name" datatype="">patrik</span></span> <span class="field field--name-created field--type-created field--label-hidden">Thu, 2016-07-28 19:20</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Just some notes for now)</p> <p>Connect to PC with HL-2303 cable. Use serial console (From Arduino IDE). 38400 baud.<br /> The mower says:</p> <p>Ambrogio Line50 Basic EUR<br /> Board AM50 5.0<br /> Built on May 24 2012 14:28:08<br /> with r12947<br /> Copyright (C) 2008 Zucchetti Centro Sistemi SPA</p> <p>TEST A: Passed<br /> TEST B: Passed</p> <p>And repeats that.</p> </div>Thu, 28 Jul 2016 16:20:33 +0000patrik519 at https://patrikhermansson.sehttps://patrikhermansson.se/index.php/node/519#comments Light sensing with a Raspberry Pi https://patrikhermansson.se/index.php/node/518 <span class="field field--name-title field--type-string field--label-hidden">Light sensing with a Raspberry Pi</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/user/1" typeof="schema:Person" property="schema:name" datatype="">patrik</span></span> <span class="field field--name-created field--type-created field--label-hidden">Thu, 2016-05-26 13:48</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>In a project I wanted to measure the amount of light in the room for controlling the backlight of a Tft display. The project uses a Raspberry Pi, which sadly don't have any analog inputs. In this case one can use a Ldr or a photo transistor with a capacitor. The principle is that you set a pin as output and make it high. This charges the capacitor. You then set the pin as input and measure the time until the Pi consideres the input to be low. The time this takes depends on how much light the detector is exposed to and will be a value depending on how much light there is in the room.<br /> This was inspired by the LDR-based Pi project <a href="https://pimylifeup.com/raspberry-pi-light-sensor/">here</a> and the one with a photo transistor and an Arduino <a href="http://learn.parallax.com/tutorials/language/propeller-c/propeller-c-simple-circuits/sense-light">here</a>.<br /> The circuit is simple. A capacitor (2.2uF) is connected in parallell with the photo transistor, which E-pin is connected to ground. The C-pin is connected to the Pi:s Gpio pin 7 (BCM Gpio4) via a 220 ohm resistor.<br /> Code: https://github.com/bphermansson/PiLightMeasure.git</p> </div>Thu, 26 May 2016 10:48:13 +0000patrik518 at https://patrikhermansson.sehttps://patrikhermansson.se/index.php/node/518#comments Light controlled tea light https://patrikhermansson.se/index.php/node/517 <span class="field field--name-title field--type-string field--label-hidden">Light controlled tea light</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/user/1" typeof="schema:Person" property="schema:name" datatype="">patrik</span></span> <span class="field field--name-created field--type-created field--label-hidden">Sat, 2016-01-23 07:18</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Electric tea lights are nice but they have a great disadvantage. There are small batteries in the base which dont last long and you have to replace them often. A modification is to remove the small batteries and add an external battery pack. The tea lights work on 3 volt, so two AA:s, rechargeable or not, will do.<br /> I also tried to add a circuit that detects the light in the room and turns the light of at daytime, no need the have the candles lit then. The circuit is designed to draw as little power as possible, otherwise the gain of the power saving would be gone.<br /> I ran this circuit with a tea light and two rechargeable GP Recyko:s in a lamp outside. I thought it would be working for a couple of months as the temperature is low from time to time, several degrees C below zero. But the lamp just kept glowing, it was almost a year and a half before it shut down! Nice indeed.<br /> Here's the circuit used:</p> <p><img src="http://www.patrikhermansson.se/files/light_sensitive_led_14.png" /></p> <p>"LED4" is the tea light, "LPT80" is a photo transistor.</p> </div>Sat, 23 Jan 2016 05:18:05 +0000patrik517 at https://patrikhermansson.sehttps://patrikhermansson.se/index.php/node/517#comments Measure light with an ESP01 https://patrikhermansson.se/index.php/node/516 <span class="field field--name-title field--type-string field--label-hidden">Measure light with an ESP01</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/user/1" typeof="schema:Person" property="schema:name" datatype="">patrik</span></span> <span class="field field--name-created field--type-created field--label-hidden">Tue, 2015-12-15 17:27</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>The goal of this project is to measure the light level in a room and send the value to a web server. One difficulty here is the lack of an ADC-pin on the ESP01 that is used. This is solved by letting a capacitor discharge through an IR-transistor, an idea taken from <a href="https://www.pololu.com/docs/0J19/1">Pololu</a>.<br /> You have to remove the connection to Gpio2 when uploading firmware.<br /> For running in stand-alone mode, remove the connection to Gpio0. </p> <p><img src="http://www.patrikhermansson.se/files/ESP01_LightMeter_schem_0.png" /></p> </div>Tue, 15 Dec 2015 15:27:35 +0000patrik516 at https://patrikhermansson.sehttps://patrikhermansson.se/index.php/node/516#comments Wireless relay board https://patrikhermansson.se/index.php/node/513 <span class="field field--name-title field--type-string field--label-hidden">Wireless relay board</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/user/1" typeof="schema:Person" property="schema:name" datatype="">patrik</span></span> <span class="field field--name-created field--type-created field--label-hidden">Thu, 2015-08-27 14:42</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>The goal of this project is to build a unit with four relays that can be controlled via Wifi. The components are mainly a ESP-03 wireless module, a ready-built relayboard and a 3V3 regulator.<br /> The software is developed in Arduino IDE and are based on the aRest-library (<a href="https://github.com/marcoschwartz/aREST-ESP8266">https://github.com/marcoschwartz/aREST-ESP8266</a>). This library makes it very simple to build controlling interfaces, a few lines of code makes it possible to control the ESP's I/O via a web based interface. The web interface contains buttons to enable/disable the relay. It is also possible to send requests to the ESP to turn on/off the relay. If you put the following address in a webbrowser the Gpio12 turns high:</p> <p>http://192.168.1.121/digital/12/1</p> <p>and low:</p> <p>http://192.168.1.121/digital/12/0</p> <p>This can also be used with curl:<br /> <code><br /> curl http://192.168.1.121/digital/12/1<br /> </code><br /> The ESP responds:<br /> <code><br /> {"message": "Pin D12 set to 1", "id": "1", "name": "esp8266", "connected": true}<br /> </code><br /> <code><br /> curl http://192.168.1.121/digital/12/0<br /> {"message": "Pin D12 set to 0", "id": "1", "name": "esp8266", "connected": true}<br /> </code><br /> To be continued...</p> </div>Thu, 27 Aug 2015 11:42:57 +0000patrik513 at https://patrikhermansson.sehttps://patrikhermansson.se/index.php/node/513#comments ESP03 https://patrikhermansson.se/index.php/node/512 <span class="field field--name-title field--type-string field--label-hidden">ESP03</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/user/1" typeof="schema:Person" property="schema:name" datatype="">patrik</span></span> <span class="field field--name-created field--type-created field--label-hidden">Wed, 2015-08-26 11:20</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>I start by flashing firmware found <a href="https://harizanov.com/2014/11/esp8266-powered-web-server-led-control-dht22-temperaturehumidity-sensor-reading/">here</a>.</p> <p>Then I can use the Arduino IDE to program the ESP. Ch_pd is connected to Vcc and Gpio15 to ground. To program, Gpio0 is connected to ground while the power is cycled.</p> </div>Wed, 26 Aug 2015 08:20:38 +0000patrik512 at https://patrikhermansson.sehttps://patrikhermansson.se/index.php/node/512#comments