Dec 1, 2017

Adapting 3xAA christmas light to USB power supply

Tired of charging batteries from time to time, I decided to power supply my christmas lights with a USB adapter.

Since these light uses 3 batteries AA, which is 3 x 1.5V = 4.5V

to adapt the 5V from the USB we need 43 ohm, aprox, so we use 50 ohms resistor.

I tested with the 5V output of my Arduino Atmel, and it work, it also works with 5V, it is brighter, but I am afraid of damaging the lights.

Sep 2, 2017

ESP8266: LoLin V3 NodeMcu Lua WIFI Development Board

Introduction


I've got me one of this ESP8266 boards to play around with my IoT project and it turns out to be a hell of configuration when you get a clone board with no much information about the hardware itself.
Later on I saw in a online shop with the description:
"This is a new version of NodeMcu Lua WIFI Development Board
Not compatible with MAC"

... great :]

So I got this board



the only it says are the following steps:

  1. Install CH340G
  2. Use 9600bsp baud rate
  3. Connect to wifi
Wemos.cc
LoLin new NodeMcu V3

So I went to wemos.cc navigated to the CH340G, and guess what, there is nothing in there
Since this is taking me quite a lot of time I decided to write here my findings on how to configure this undocumented breakout device configuration.

Warning!
The following steps are valid for this ESP8266 board LoLin V3 NodeMcu from wemos.cc and Macbook pro OS X Yosemite 10.10.5. I don't know if such steps are valid for any other configuration, so be carreful, if you have different configuration search for another tutorial.


This blog describes quite similar board:
http://ouilogique.com/NodeMCU_esp8266/
and with the help of google translator i figured things out.

 

Installing CH340G for OS X

I am using OS X Yosemite 10.10.5 so installing the UART driver it is not as trivial as on Windows.
I found this driver that works for me:

http://ouilogique.com/files/2015-05-21-ch340_driver/CH34x_Install_V1.3.zip
in case the link is broken you can download it from here

Once installed you connect the board to your USB and check the port.
open the terminal and type:

ls /dev | grep tty.w

you should see one of the two serial port adaptors:

 /dev/tty.wchusbserial1410 
 /dev/tty.wchusbserial1420 

Note: The number depends on which USB port you connected the board: USB left or right
If you dont see any of these ports then you need to restart you computer. Otherwise check the USB cable, if still not working then someting went wrong with the driver installation.

Installing Esptool

Esptool is a python script that helps you to interface with your ESP8366 over the USB port.
To install python tools do:
Go to your temporal folder or any other folder where you can download the installation source, then

git clone https://github.com/themadinventor/esptool.git
cd esptool
sudo python setup.py install
which esptool.py # ⇒ /usr/local/bin/esptool.py 


The last command "which" it is to check where the script was installed.


First commands with esptool

Now let's try if the ESP8266 works. Open your console and type:

esptool.py -h

you will see the help page for esptool and how to use it.
Let's check the mac address of the ESP8266:

esptool.py -p /dev/cu.wchusbserial1410 read_mac


Notice that the command requires the port name, with the format: 

esptool.py -p <PORT_ID> read_mac

remember that you may have the other name /dev/cu.wchusbserial1420

Then the result of our querry is, in my case:
esptool.py v2.1
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266
Uploading stub...
Running stub...
Stub running...
MAC: 5c:cf:7f:XX:XX:XX
Hard resetting...


Where 'X' is a Hexadecimal numer.

you can also try to read the chip id with the command:

esptool.py --port /dev/tty.wchusbserial1420 --after no_reset chip_id

or the flash size which it is important to know if you want to upgrade the NodeMcu version

esptool.py --port /dev/tty.wchusbserial1420 --after no_reset flash_id
esptool.py v2.1
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266
Uploading stub...
Running stub...
Stub running...
Manufacturer: ef
Device: 4016
Detected flash size: 4MB
Staying in bootloader.


I have tried ESPlorer, which is a Java application to communicate with the ESPXX but for me does not work. I can open the port but I do not receive any answers from the ESP8266, You can have a try if you want:

http://esp8266.ru/esplorer/

You can also check the flash id in order to find more information about the chip.

esptool.py -p /dev/cu.wchusbserial1420 flash_id 
esptool.py v2.1
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266
Uploading stub...
Running stub...
Stub running...
Manufacturer: ef
Device: 4016
Detected flash size: 4MB
Hard resetting...


now, with the manufacturer "ef" you can search on the following file the id of the corresponding manufactures.
 

https://code.coreboot.org/p/flashrom/source/tree/HEAD/trunk/flashchips.h

in my case "ef" refers to:

W25X chips are SPI, first byte of device ID is memory type, second
byte of device ID is related to log(bitsize)
 
#define WINBOND_NEX_ID␉0xEF␉/* Winbond (ex Nexcom) serial flashes */

Buildting your frimware on the cloud
Here you can customize the firmware your want for your board and the you will receive a email with the link for downloading it.

https://nodemcu-build.com/

Flashing the firmware

I followed the steps from the following link and it worked just fine

http://nodemcu.readthedocs.io/en/master/en/flash/

esptool.py --port /dev/tty.wchusbserial1420 write_flash --flash_mode dio 0x00000 nodemcu-master-9-modules-2017-10-08-17-51-52-integer.bin
 

esptool.py v2.1
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0240
Compressed 405760 bytes to 262269...
Wrote 405760 bytes (262269 compressed) at 0x00000000 in 23.5 seconds (effective 137.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting... 


Flash mode is dio because my board is a >=4 MByte modules. This is explained in the tool overview. The address is 0x0 because I am using the full firmware bin package (see ref) and I dont need to set the board in bootloader mode because since I am using USB direct connection this is done by the tool (see ref)




May 15, 2016

Fixing the pedal effect Zoom 707 II Guitar

If you have a pedal effect Zoom 707 II for Guitar and it makes some cracking noises, probably sooner or later will stop working, as it happened to me. This is an old pedal effect I have since 2003, I remember I paid for it about 270 €. I used it a lot, and apparently because it was always on the floor and sometimes when people walked over it, kicked or stepped on the cables, this jack connectors eventually got damaged.





So I decided to open it and see if I could fix it.
The first thing you have to do is to remove the three potenciometers, right under the brand, pull them off gently.
Then flip the pedal, and start unscrewing. When you are done, be careful when you open it, because there is a cable connecting the cover to the Wah pedal, you can just disconnect it pulling it off.

So here it is, the internal circuit board, after 11 years it doesn't have so much dust.
As you can see there two jack connectors. Mine had the input connector damaged


As you can see in the center of the image below, on the right hand side of the spring, there are 3 weldings, these are, +, - and ground.
When I connected the Jack, and swinged it a bit it, I could see that one of the welding was moving, this avoid the signal to go through.
So I took my soldering machine and I just drop a bit of solder wire on it, and done, I have pedal effect for 10 more years





Nov 7, 2012

Modules updated

Re-designing the code


Finally I've got some time to update the files to github. The after having a break for a couple of months I realized that my first approach was wrong, the classes were dependent, therefore I redesigned each of the for having independence among them.

Some tests need to are bounded to several classes, e.g. the most of the class need the class LCD to show the behavior or result of the tests.

When I re-designed the classes I had also to rename some of them. At the time of updating this to github I encountered with a problem. I had removed or rename the files on my local computer so when I did commit and push them to the server, the server kept the old files and the new. There was no way to remove them. Was then when I found the following command that helped me to remove the old files from the server, and update everything as it was on my local computer:

git add . -A
git commit -m "removed some files"
git push origin master

This is the list of new classes:


DHT11
Sensor of temperature and humidity. I took the code from http://arduino.cc/playground/Main/DHT11Lib in which I did some minor changes.

Keypad
Now this class only controls the keypad and does not include the LCD, Even though are both in the same board. I believe this way is more clear for use it, and the code is grouped by functionality and cleaner.

LCD
This class only writes on the display, nothing else. Actually is the wrapping of the LiquidCrystal class where I merged a couple of function to make the writing easier.

LEDRGB
This class remains almost the same, what before was test now is function of the class. So the test only calls the functions.

MenuController
This class controls the index of the menu but is not a menu itself. does not contain titles/text. That will be performed by the class Menu in the future.

Relay4
Represents the board Channel Relays. It offers the basic functions for controlling the relays.

Test samples.
Now the tests are clearer, shorter and easier to run.



What is next.



I'm thinking about a good way to generate a Menu dynamically and reusable, with a main index and each item containing options, any suggestions?

Aug 25, 2012

Interactive menu with keypad and the LCD display

After make sure that each button is recognized properly by the software I created a class called Menu.

This class is for controlling the menu's options, reacting to the buttons' events:
UP, DOWN, LEFT  and RIGHT.

Basically the menu has four options, they are listed as follow:


1 - LIGHTS
2 - WATER PUMP
3 - FAN
4 - HUMIDIFIER

The program starts showing the option 1 - LIGHTS. Pressing the buttons UP and DOWN you can scroll the menu. Boundaries were established to not let the buttons scroll more than available options.
With the LEFT and RIGHT buttons you can set ON and OFF the status of the output which is not implemented yet. The status is shown on the bottom right corner.


Source code now is available on GitHub

I was configuring my account on github for sharing this code, feel free to take a look and fork it ;)

Source code


Aug 19, 2012

First test with LCD Keypad Shield

I've got my LCD Keypad Shield two days ago. I bought it for 8 € in dx.com Here is the link if you are interested to buy one.

LCD Keypad Shield



I was not sure if this Shield would fit in my Arduino Mega. Fortunately it did. Now, I tried to use some of the examples from the Arduino but they did not work properly.
Since I don't know even which model is this shield and I don't have any documentation, I took a code from freetronic and checked how this thing works. By the way there is nice explanation about how the buttons are connected to a single analog input (A0).

Check the article here

I ran the example and it did not work because this code is for freetronic not for this one. so I went through the code and I noticed that Arduino reads the A0 to figure out which button was pressed. There is a range of voltages for each button. Now, what I did was to show in the display the voltage of the pressed button down on the right corner of the display.
As you can see in the image, pressing the Down button generates 308mV. These are the values I got.

  ADC voltages for the 5 buttons on analog input pin A0:

    RIGHT:  0.00V :   0 @ 10 bit
    UP:     0.71V :       133 @ 10 bit
    DOWN:   1.61V :  308 @ 10 bit
    LEFT:   2.47V :     481 @ 10 bit
    SELECT: 3.62V :  722 @ 10 bit

I adapted those values in the code and now it works!

#define RIGHT_10BIT_ADC           0  // right
#define UP_10BIT_ADC            133  // up
#define DOWN_10BIT_ADC          308  // down
#define LEFT_10BIT_ADC          481  // left
#define SELECT_10BIT_ADC        722  // right

This are the lines you can uncomment to see the voltage of each button:

   //debug/test display of the adc reading for the button input voltage pin.
   lcd.setCursor(12, 1);
   lcd.print( "    " );          //quick hack to blank over default left-justification from lcd.print()
   lcd.setCursor(12, 1);         //note the value will be flickering/faint on the LCD
   lcd.print( analogRead( BUTTON_ADC_PIN ) );
   delay(500);


Notice that I change the location of the message for the second row and also put a delay.