23 December 2014

Nativity scene light effects with Arduino - the code

And here is the code of my simple light effects. As shown in the previous post I used an Arduino-compatible board called "Pro Micro", compatible with "Leonardo". But any other variant will do.



/*
 Nativity scene lights

 This code controls two LEDs used to animate a Nativity scene.
 A normal LED connected at lampPin goes off during the simulated day.
 A high power LED (use an appropriate driver out of sunPin) simulates
 daylight, including sunrise and sunset fading.

 The circuit:
 * 5mm LED attached lampPin through a 1k resistor and 5V
 * high powered LED driven with an IRF510-like out of sunPin. It
   connects to Vcc through a limiting resistor (do your math and
   take heat dissipation into account).

 Created 20 Dec 2014
 By Paolo Cravero IK1ZYW

 Based on the official Arduino example "Fading":
 http://arduino.cc/en/Tutorial/Fading

 This code is in the public domain.

 */


int sunPin = 3;  
int lampPin = 9;

void setup()  { 
  pinMode(lampPin, OUTPUT);
  digitalWrite(lampPin, LOW);
} 

void loop()  { 
  // fade in from min to max in increments of 1 point:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) { 
    // sets the value (range from 0 to 255):
    analogWrite(sunPin, fadeValue);         
    // wait for 50 milliseconds to see the dimming effect
    // adjust to your taste
    delay(50);                            
    // lampPin trigger is at 50
    if (fadeValue > 50) {    
      digitalWrite(lampPin, HIGH);
    }

  } 
  
  // duration of the day, 20 seconds
  delay(10000);
  delay(10000);
  
  // fade out from max to min in increments of 1 point:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1) { 
    // sets the value (range from 0 to 255):
    analogWrite(sunPin, fadeValue);         
    // wait for 50 milliseconds to see the dimming effect    
    // adjust to your taste
    delay(50);                    
    // lampPin trigger is at 50. Feel free to have hysteresis
    if (fadeValue < 50) {    
      digitalWrite(lampPin, LOW);
    }
  } 

  // duration of the night, 20 seconds
  delay(10000);
  delay(10000);
}

       
 

Nativity scene light effects with Arduino

It's Xmas time again. At home we deployed our usual nativity scene that had been joined by a simple 3V lamp for the barn, a couple of years ago. I wanted something more lively for my daughters, as well as something that originated from my hobby interests.

The idea: build a day/night simulation and switch on/off the barn lamp accordingly. Simple enough with an Arduino-like board and few lines of code.

How to simulate the Sun light, dimmable with PWM? The most intense light emitter I could find at home is a 1W warm white LED mounted on the "star" heatsink.

Step 1. If I let little Sun_LED draw 150 mA it doesn't warm up (to the touch), so I don't need a bulky extra heatsink. But I need an interface out of the Arduino board, because it cannot supply that much current. A good old IRF510 does the job (without heatsink).

Step 2. The 3V incandescent lamp drains 120 mA! I am lazy, in a hurry, and I don't want to add extra components to deal with it: a white LED does the job with 1/20th of electrons.

Last but not least, the whole thing is powered with a variable voltage wall-wart adapter. Since the Sun_LED is tied to the main Vcc supply through a limiting resistor, I can control Sun_LED maximum brightness with a flip of a switch.

Code and video will follow.

Improvements. My daughter asked for a moving figure: we will try to buy one during after Xmas clearout, possibly that works with DC. "I myself" though of simulating not only the fading of sunlight, but the color excursion too. I will buy a power RGB LED and play with it during 2015.

21 December 2014

ESP8266 really works on 802.11n?

Now that I got acquainted with ESP8266 WiFi module peculiarities, I have been asked if it works on newest 802.11n wireless networks. According to the datasheet, the ESP8266 chip supports 802.11b/g/n standards.

So I am setting up to test it against an "n only" access point. I will report my findings, since my home AP only does b and g.

09 December 2014

My best DX on 23 cm so far

My usual DX on 23 cm is 136 km during the monthly activity contest. Last Sunday there was the 50th anniversary of the Vecchiacchi V/U/SHF contest and I wanted to pay my tribute to the event.

All I could do was to spend the last contest hour on the air on 23 cm SSB. I was logged to the on4kst chat and got a request from a station 368 km away.

My 23 cm setup consists of a transverter with about 15 W out, 5 metres of SAT-TV coax and a 23 cm Yagi on the balcony, with "hand-rotor". The DX station was checking aircraft positions so that we could attempt an Aircraft Scatter QSO. At the first try my antenna was beaming too North. Then I adjusted it to what should have been the right direction and ... BINGO! The QSO was completed. We used three airplanes, that made a very long opening on our path.

Luckily I guessed how much off-frequency my transverter is!!

It is amazing how well AS works. Much similar to MS, but much more predictable!



30 November 2014

ESP8266 finally hears Arduino

As stated 18 days ago, I took a break from trying to make an Arduino board talk to an ESP8266 WiFi module. In the meantime I have both updated the 8266 firmware and received level converters.

Nothing changed: still no data flow from Arduino to ESP8266 over the hardware UART.

After three nights spent debugging software and hardware, trying to understand why both of them could happily speak to a computer, one at a time, but not to each other, I took the last chance: I fed directly the Arduino output at 5V/TTL. Make it or (literally) break it.

Well, it simply did it.

My ESP8266 specimens seem to be a "deaf" at 3.3 V, but they happily accept data at 5 V (datasheet says inputs are 5 V tolerant). ESP8266 power supply remains at 3.3 Volts.

More than ever, YMMV (Your Modules May Vary). I am not suggesting this procedure as standard practice. I report it worked for my specimens.


11 November 2014

Come aprire il tablet Mediacom SmartPad 820c

(This post is in Italian language since Mediacom products seem to be known only here...)

Mi è capitato un tablet Mediacom SmartPad 820c con questo difetto: si inserisce il caricabatterie, lui da solo inizia la procedura di accensione e dopo circa 10 secondi si spegne il display per ricominciare tutto da capo. La batteria non carica.

Avendo vissuto una esperienza simile su uno smartphone Galaxy S2 che ha comportato la sostutizione di un circuito integrato (in garanzia!), ho aperto il tablet.

Contrariamente a quanto si potrebbe pensare, non bisogna forzare sotto il coperchio posteriore in alluminio o la plastica nera, ma tra il display e la striscia blu in plastica. Qualche vecchia carta fedeltà fa al caso nostro:



Si comincia dall'angolo in cui si apre lo sportellino e si fa tutto il giro.

Un po' sospettavo la batteria, come visto sul mio tablet Mediacom. Ma in questo caso non è assolutamente gonfia e mostra una tensione di 3,2 V (è solo scarica). Il problema sembra proprio essere nel circuito di gestione della carica.

Si potrebbe scollegare la batteria, ricaricarla esternamente e ricollegarla, per recuperare i dati. Ma la decisione spetta al proprietario dell'oggetto.

Purtroppo il difetto si è presentato una settimana dopo la scadenza biennale della garanzia. E non pensate male!

10 November 2014

ESP8266, taking a break

After too many hours spent trying to make an Arduino board talk to the ESP8266 module, I decided to take a break and:
  • buy a 5V/3.3V level conversion module
  • upgrade ESP8266 firmware while waiting for the delivery
With the upgrade I should be able to reduce the serial speed to a more bearable 9600 baud and hopefully get more consistent behavior of AT commands.

I even built a converter board based on a circuit I found online. I replaced 2N7000 with BF245 from my FET drawer but all I got was wrong voltages or a form of short circuit. Nevermind, even if I am loosing a chance to learn something new, I do not have enough time for this kind of troubleshooting: I want to have that WiFi board working and uploading data!

07 November 2014

Filtering ESP8266 power supply

If your ESP8266 behaves erratically, the cause could be in the power supply.

Not every experimenter is properly equipped with a reliable 3.3 V source, neither was I. So I built a downconverter to power the ESP8266 WiFi board. The LF33CV LDO regulator should supply 500 mA continuous: plenty of headroom for the 200-250 mA peak requirement.

I configured my modules to join the home WiFi network a startup. A simple test for their presence is to run a network ping (the smartphone and Fing app comes very handy). When powered with the USB-to-serial converter, the round-trip-time smartphone<>ESP8266 was of 10 ms or so. That is: send a small packet of data to the remote device and measure how long it takes to come back the acknowledgment.

When I moved to the stand-alone circuit I started getting lost packets exceptions and much higher RTT.

I looked at the 3.3 V line and noticed anomalous spikes when the LDO was used. Instead the DC line was much smoother with another 3.3 V source.

A simple extra 220 uF across 3.3 V and GND fixed it. Actually I even improved RTT of a couple of milliseconds.

So, decouple that 3.3 V line!

06 November 2014

My ESP8266 initialise sequence

For my personal records, and the worldwide community, here is how I initialised my two identical ESP8266 modules bought in September 2014. As usual with these almost undocumented electronics, YMMV: your module may vary.

All commands are terminated with CR and LF and not echoed locally (this is a setting of your terminal).

The module comes in AP mode: it acts as an access point. I wanted to use it as a normal device on my home network, so I changed it to "sta":

AT+CWMODE=1

This setting requires a cold restart of ESP8266. I am not sure a soft reset AT+RST is enough.

Now it is possible to join the local WiFi network:

AT+CWJAP="yourWiFinetworkid","yourWiFipassword"

To check if it has joined the network issue:

AT+CWJAP?

It will return the string +CWJAP:"yourWiFinetworkid"

Assuming your hotspot has a DHCP server, the assigned IP address is shown with:

AT+CIFSR

That's it, the device is connected. It will reconnect at each power cycle. As is it will not do anything useful, just reply to IP ping.

Again, YMMV.
(in other words: I am not able to offer support of any kind)

05 November 2014

ESP8266 cheap WiFi-to-serial module

After reading positive comments, I jumped on the ESP8266 boat.

The ESP8266 chip/board is a WiFi-to-serial adapter (yeah, the "so 70's and 80's" serial port!), which includes a TCP/IP stack and a WiFi Access Point. It can work as a server on your home network, or as an "Internet of Things" (IoT) client, or accept WiFi connections from other devices. Just use your imagination and do some advance planning. All for 5 USD or less.

These boards run at 3.3V, so there is need for a level converter to use them in pair with Arduino and a separate power supply/adapter. Or buy a 3.3V Arduino board (it will run at 8 MHz instead of 16 MHz clock).

There are a few Arduino libraries around, so life is quite easy as long as you understand all limitations involved (for example you will not stream video over a 115200 bit per second channel with a 64 bytes buffer).

My ESP8266 modules remember the AP setting, user and password, so they connect automatically at powerup. Unfortunately they do not auto-start the TCP server, so a microcontroller is needed. Or a new firmware can be flashed ... or developed if you're brave enough!

03 November 2014

Back on 30 m CW - 2014

In a spike of interest for HF operations, I re-erected my 10 MHz monopole already featured on these pages. I haven't been there for a couple of years, and now we are closer to the solar cycle peak than my last appearence on 30 metres.

May be it is my antenna, or the propagation. I am getting very strong signals from very close stations. Even just 200 km away. Everyone is 599+ for real, sometimes I even have to use IPO or ATT on the FT817. And of course I have no troubles to be heard. I even got a reply during a test CQ at 500 mW.

I should connect my SW-30+ and finally have a QSO with it, even if it is not completely boxed yet.

Oh, by the way, I am sweating my way out of CW QSOs. No digital contacts this round.

29 October 2014

Deterministic error in temperature measurement (BAR206) - results

As announced, I opened my Oregon Scientific BAR206 station. The back cover comes out with a little help to unlock a small hook on both longer sides: just be careful. The circuit inside mine look like this:

Inside an Oregon Scientific BAR206

Humidity and temperature sensors are easily spotted, as highlighted in the picture above. With a bit of surprise, the temperature sensor is an analogue thermocouple. I found its tip sitting on the resistor, which could be the cause of the +0.5 °C constant error, added with an insufficient air flow.


I lifted the thermocouple and began the experimental comparison with an external sensor, one next to the other, BAR206 being without back cover (higher air flow).



Much to my disappointment, but without too much surprise, BAR206 body continued measuring 0.5 °C more than the external sensor. This confirms the observation at my parents' place with other three Oregon Scientific thermometers (one internal sensor in another model, two external sensors).

So this must be a firmware error or a design issue of analog circuitry inside BAR206. Even though some solder joints look awful (look at the huge blob under the thermocouple tip), the reason must be somewhere else. I may write to Oregon Scientific, but their specs say the accuracy is +/- one °C.

From now on I will mentally deduct 0.5 °C from the internal reading.

You may ask: why bother? I am an Engineer, I love accurate measurements and, most important, I hate recurrent (design) errors.

27 October 2014

Deterministic error in temperature measurement (BAR206)

I had doubts, but not a second device to do some tests, until my father bought himself an Oregon Scientific BAR206 radio-controlled clock and weather station, like mine. He noticed a difference of +0.5°C in the measurement of indoor temperature between BAR206 (production code 11A13 ?) and his old station.

So we gathered all his external sensors in one place and waited for readings to settle: BAR206 internal sensor was 0.5 °C higher. One value against three values.

I repeated the test at home with my BAR206 (production code 05A11 ?) and I could confirm the extra half-degree.

I think the reading error is due either to a firmware bug or the tight case that doesn't let air to flow inside.

I will now remove the back cover and see what happens. Check back for results.

16 October 2014

Lithium balloon!

Remember the inflated Li-poly battery I extracted from the family tablet? I had it laying on the balcony for two weeks, where it could release dangerous gas or catch fire without much damage.

Since it looked more inflated than ever, I checked it out. The inner pressure had now reached a level where I could not press the outer film: it felt like a properly inflated bike tire!

I am not planning yet a visit to the recycling centre, so I decided to vent the Lithium cell in order to avoid an explosion. A pin easily drilled a few holes in it (in open air!!) and internal pressure was released.

02 October 2014

Inflated tablet = inflated lithium battery!

Having an inflated tablet with a suspect inflated lithium battery inside the house is not a situation that should last long. Failing Li-xx batteries can release gas or catch fire, something I do not want to explain to my family and neighbours.

So I opened the Mediacom 930i tablet, that was half-open anyway, and finally saw the battery pack inside these devices. My tablet has two 4000 mAh cells in parallel and as expected one of them was puffy:


One of these Li-po cells is 3 mm thick or so: they could make an interesting battery pack for radio use, i.e. to fit inside existing equipment (FT817 and others). The cell on the right, incidentally where the liquid blob and backlight anomalies were, was swollen.



To the touch it felt like a partially inflated baloon.

I measured the voltage across red-black terminals and it read 3.65V: the two cells are in parallel.

What I did next was to carefully remove the blue tape in order to separate the puffy cell, cut its terminals to get it loose and lay it outside in an area where a casual flame would not set something on fire. Interestingly the swollen cell still held the charge. Inside the "battery pack" there was some sort of circuitry that I have not investigated, probably to select the most charged cell.

I was left with one good cell inside a working tablet device. It has been recharged overnight and now we have a tablet 80 grams lighter :-)





01 October 2014

Inflated Mediacom Tablet

Last time I picked up the tablet at home (a Mediacom Smart Pad 930i) I noticed it wasn't flat anymore. Looking at it through the short side I saw this:


The back cover has been pushed away and the display was bent too, as if someone had inflated a balloon inside it. I immediately suspected a faulty battery, but the tablet was working and holding the charge.

Actually a first sign of failure appeared one month ago on the display in the form of a liquid blob stuck under the glass:


But I though it was because of mishandling during holidays or just a failure after two years from purchase (warranty is over). The tablet never fell off. Another sign I have not recorded in pictures was a difference in backlight intensity in the border and one brighter spot above the apparent liquid leak.

These two alterations could be an early sign of upcoming battery failure in a tablet.

Next step: opening it up and getting rid of the battery, as soon as possible!

TBC

(For searches in Italian language: Batteria gonfia nel tablet Mediacom Smart Pad 930i. Continua nel post successivo.)

29 September 2014

DIY component tester (kit) - reading the microcontroller

Since the component tester kit was shipped with firmware version 1.05k, I would like to flash the newest 1.11k code available online from the original developer.

I do not have a spare ATmega328P at home, only ATmega168P's, so first I tried to dump the original 1.05k firmware: the chip is fully locked. I cannot even read current fuse settings without erasing it.


Too bad. I will now study limits of the code running on ATmega168 which has half the program space available of an ATmega328. Then, in case, buy (online, sigh) another microcontroller to experiment with.

27 September 2014

DIY component tester (kit) - assembled

The aforementioned component tester kit can be assembled in 60-120 minutes, depending on your soldering skills.

Not much to say about it. Components must be inserted on the side with solder mask ("top") and soldered at the other side. Just keep transistors close to the PCB and mount both the socket for IC and the pin-header for display.

There is no specific assembly order since the board is pretty wide. Sit down and have fun.

25 September 2014

DIY component tester (kit) - arrived

In just 17 days the kit of the DIY component tester has arrived (by non-Registered letter).





The envelope contained the bag with components and PCB, nothing else. PCB markings are clear enough, so you only need to identify the part, put it in place and solder.

I suggest using an ohm-meter to identify resistors, and a magnifier for transistors and capacitors.