Wednesday 25 November 2015

Using node.dsleep() in NodeMCU to extend battery lifetime in ESP8266 projects

For some applications, like checking sensors, the ESP8266 does not need to run permanently with all it's bells and whistles on. The datasheet claims 10uA when in deep sleep mode.
NodeMCU, currently my preferred firmware, does support that sleep mode, but I've never tried using it. Mainly because it is a pain to modify the ESP-01 which used to be my perferred module.

Olimex MOD-WIFI-ESP8266-DEV

With the Olimex modules, I aquired a while ago, trying this out is a piece of cake. Both the reset-pin and GPIO 16 are freely accessible. The ESP8266 wakes up from deep sleep on a falling edge on the reset pin. This signal does not necessarily need to come from GPIO16, but can also be generated externally.

The brown wire does it all

NodeMCU syntax

It is explained in detail here. Basically it is:

node.dsleep(Time-In-uSecs , option)

Where "option" can be 0-4. But I don't quite understand the "0" option yet.
If you send it to sleep for 0 useconds, you'll need to trigger the wakeup from an external source.

Power considerations

In my experiments, the running module took around 70mA from it's 3,3V supply.
In deep sleep mode, the module draws a little less than 0.8mA which is great and will run the system for months with a good 18650 rechargeable battery. Still it is quite a bit more than the 10uA from the data sheet.
Looking at the Olimex datasheet, two things come to mind:
  • The SPI Flash memory (W25Q16BVSSIG) has a 25-50 uA standby current and can peak to 25mA when active.
  • There is a power LED with a 2k resistor that is constantly on and will probably account for most of the current
Another interesting option to node.dsleep() ist option 4, which leaves WiFi disabled when waking up. This saves a lot of power while the system can read sensors or process other information. I've seen it draw around 12mA in this mode.

Video

I've also documented that in a short video on my youtube channel.

Todo

Try the same with an ESP-12 that has no LED

Wednesday 18 November 2015

Microsoft surface pro 3 USB overcurrent protection vs iPhone 6s

At work, I got a new iPhone 6s the day before yesterday. This morning the battery was down to about 18% because I used it to track a 13km run last night, listened to some podcasts and played ingress on the way back from walking the kids to school.
So when I plugged the phone into the docking station of my Surface Pro 3 (i5 model), a message window came up:
Poorly translated error message
The message "Stromüberspannung am USB-Anschluß" literally means "Currentovervoltage on USB port". Ouch, this sounds so wrong!
I suppose it means to say that the over current protection has kicked in and the port needs to be reset.
This worked and the iPhone started charging/synching.

Next day: measure current


The next day I brought my USB meter. The phone was around 30% when I took this picture. The PC didn't complain. So I suppose yesterday's current was even higher than that.

A little over 1A from an USB3.0 port
According to Wikipedia that is out of specs for an USB3.0 port:
Source: Wikipedia
Over time the current drops to acceptable levels:

  • At 70% current is down to 0.6A
  • At 95% current drops to 0.45A
  • At 100% it is down to 20-70mA

All of this is within specs. But it seems that a well discharged phone draws too much current.

23.11.15:
My iPad Air charges at 0.46A from the same USB port, while it takes 2.2A from the original charger. That's what I'd expect. The 6s charges at 1A from that charger, although rumor has it that it can charge at 2A, I have yet to see proof of that.

27.11.15:
Again the phone was down at 7% and the same message came up. This time I had my USB meter with me. 1.3A is clearly too much.What still puzzles me: When I connect it to my 2A iPad charger, it only takes 1A.

Next: Try other phone



Tuesday 17 November 2015

Flying the Cheerson Sanlianhuan CX-10C camera drone

This blog article is a companion to this youtube video on my channel.

Despite all their limitations, I like the Cheerson minidrones. They are inexpensive, rugged and fit into any jacket's pocket. So they're ideal to take with you on a walk and are great to teach the kids a thing or two about flying. Being a licensed pilot myself (well - for paragliding, that is ), I simply enjoy the occasional flight.

I have both the

  • CX-10 which used to be the world's smallest drone for some time

and  the

  • CX-10A which is a headless version of the above. The headless mode (tap the left stick 2x) takes a lot processing power off the pilot's brain and makes flying easier for the kids. 

We had a little fun with those two in the office and of course one of the first questions was:

"It doesn't have a camera, does it?"
"Naah, no way. That thing can never possibly carry a camera"

Little did I know that only a few months later, the world's smallest camera drone hit the market.
Once the price was down below the magic (German customs regulation) 22€ mark, I ordered one straight from the PRofC. It also has a CE mark on the box, which means it won't get stuck in customs for safety / EMI reasons.

Unboxing

Last week I was delighted to find that CX-10C drone in my mail.
Contents of the package

Setup

It is a little higher that the CX-10 / CX-10A and significantly heavier. I inserted a FAT32 formatted 2GByte micro SD card. - The card's contacts have to face UP when inserting.
PowerBanks are very handy to charge the CX-10C

I charged the battery from my XIAOMI power bank which has the added benefit that it turns off once the charging current drops below (TODO: measure current) mA. The charger does not appear to offer any protection against overcharging. (TODO: double check this) 
To my amazemt, the charge current drops to zero then the LED goes out. So the battery doesn not overcharge.
In all other blogs, the battery capacity is quoted as 120 mAh. On my box it clearly says: 80 mAh
Looks like it only has a 80mAh lipo cell

Flying

I took it to a nearby park for a first test. The first thing I noticed was the sluggish climb rate. The CX-10/A responds far more aggressively to the throttle. Pitch and roll are very low in the default ("junior") mode. That is great to get stable video recordings, but the copter will be blown away even in light winds.
During flips, the drone loses about 1 to 1,5 meters of height. In the older, lighter models this was very well compensated. It is still amazing that it still works, given the increased mass of the thing.

Still pictures

The stills are obviously not great.

Unprocessed still. - Original size

Video recordings

See my youtube video for some of my recordings.
Videos appear over-sharpened to me, which makes the 640x480 resolution appear better than it actually is. If the sun is low on the horizon, colours are a bit washed out.
It is amazingly good in low / artificial light.


Pros:

  • low cost (below 22€ on ebay)
  • CE mark
  • light weight / portable
  • safe - won't hurt too much if you accidentially hit someone
  • ok video quality for the money


Cons:

  • No camera gimbal, so any front/back/side movement will make the viewer seasick.
  • No headless mode. That would make it easier to concentrate on shooting video footage.
  • Poor flight-time vs charge-time ratio
  • No proper charging circuit
  • handles a bit sluggish / poor weight vs power ratio

Final word:
Yes, you want that. It's fun and it's cheap.

Monday 2 November 2015

Building the DSO138 portable oscilloscope

A friend of mine once said:
"All it takes to assemble an electronic kit is a trained monkey."
While the construction of this kit did in fact not take much brains, it would take a very nimble fingered monkey to do the SMD soldering.
I couldn't have done it without a little help from my magnifying lamp
My somewhat yellowed, late 80s Ersa 230 - 15W iron's conical tip shouldn't have been any wider, but was ok for both the resistors and the IC.
The through-hole components were not a problem at all. I just misplaced two components and the solder is very hard to get out of the through-plated holes. So better double-check before soldering.

The instructions are nicely printed in colour and, easy to follow and include full schematics.

As an alternative, for just one extra euro, there is a version available that has all the SMD components in place already.
Very neat measurement readout
This thing is not a replacement for a fully featured scope. Still I'll try to get it into a 3d printed enclosure like this one, to use it as a portable scope.
Equipment needed:

  • Soldering iron 15W / conical tip
  • Fine tweezers
  • Desondering pump / braid (just in case)
  • Solder 1,0mm or less
  • Small soft wire cutters
  • Magnifying lamp (if you're over 40)

Bottom line: Fun little project for just over 20 bucks. Not really worth the effort if you already have a scope.