We interrupt this program

JeeLabs - Tue, 21/04/2015 - 23:01

… for an important announcement from our sponsor:

Just kidding, of course!

But it got your attention, right? Good. That’s what this week’s episode is about: taking care of something unexpected, i.e. processing tasks without planning them ahead all the time.

On the menu for the coming days:

Interrupts – when handled properly – are extremely powerful and can deal with “stuff” in the background. But there are a lot of tricky cases and hard-to-debug failure modes. It’s worth getting to grips with them really well if you want to avoid – unexpected – failures.

(For comments, visit the forum area)

Categories: Community Blog posts

Dataflash via SPI

JeeLabs - Tue, 14/04/2015 - 23:01

One of the things I’m going to need at some point is additional flash memory. Since the simplest way these days to add more memory is probably via SPI, that’s what I’ll use.

This week’s episode is about connecting an SPI chip, implementing a simple driver, code re-use, the hidden dangers of solderless breadboards, and point-to-point soldering:

The end result is several megabytes of extra storage, using only 4 I/O pins. Data logger? Serial port audit? Storage for audio, video, images? Your next novel? It’s all up to you!

(For comments, visit the forum area)

Categories: Community Blog posts

Analog on the cheap

JeeLabs - Tue, 07/04/2015 - 23:01

Digital chips can’t do analog directly – you need an A/D converter for that, right?

Not so fast. Just as pulse-width modulation (PWM) can be used to turn a purely digital signal into a varying analog voltage, there are tricks to measure analog values as well.

All you need is the proper software, a simple analog comparator, and these components:

This week’s episode examines delta-sigma modulation and shows you how it’s done:

There’s in fact a little gem hidden inside those LPC8xx chips which allows implementing this without bogging down the µC. Just one interrupt whenever a measurement is ready. But the basic idea is applicable to any microcontroller with a built-in analog comparator.

(For comments, visit the forum area)

Categories: Community Blog posts

Funky v3 with RFM69CW using LowPowerLab’s RF69 library

mharizanov - Sat, 04/04/2015 - 19:00

I’ve already blogged about using Funky v3 and RFM-2-Pi with the HopeRF RFM69CW module, only I used it with JCW’s Jeelib as I wanted to keep compatibility with my existing RFM12B based sensor network. JCW has done great job in providing compatibility with the RFM12B by tweaking the chip’s registers so that it becomes an easy replacement.

Felixs’s RF69 library on the other hand has native support for the module, including hardware encryption out of the box. Some of the library features:

  • 255 possible nodes on 256 possible networks
  • 61 bytes max message length (limited to 61 to support AES hardware encryption)
  • customizable transmit power (32 levels) for low-power transmission control
  • sleep function for power saving
  • automatic ACKs with the sendWithRetry() function
  • hardware 128bit AES encryption
  • hardware preamble, synch recognition and CRC check
  • digital RSSI can be read at any time with readRSSI()
  • interrupt driven
  • promiscuous mode allows any node to listen to any packet on same network

I wanted to test it for quite a while now, so with a quick customization for Funky v3 compatibility, I got these two sketches to play some over-the-air ping-pong. Basically one is a sender and the other is a receiver and it is ideal to test range. I placed the transmitter in my kitchen and was able to get reception in all of my house, both stories. I got reception outside the house and in all of the yard, including in a shack 15m from the house and with 4 walls between the transmitter and receiver. Pretty impressive, given that the RFM12B wouldn’t even cover all rooms inside the house. That of course comes at the cost of increased power consumption, so it is a balance between needs for range and low power.


Categories: Community Blog posts

Emulating EEPROM

JeeLabs - Tue, 31/03/2015 - 23:01

The LPC8xx series has no EEPROM memory. This type of Electrically Erasable memory is very useful to store configuration settings which need to be retained across power cycles:

But we can emulate it with flash memory, despite the somewhat different properties.

Here’s the why’s, what’s, and how’s of this software trick – in this week’s article series:

There’s quite a bit of detail involved to get this right, as you will see.

(For comments, visit the forum area)

Categories: Community Blog posts

Using DS18B20/DHT22 temperature sensor with internal pull-up resistors rather than external ones

mharizanov - Fri, 27/03/2015 - 19:57

I’ve been meaning to try Josh’s 4-line change to the OneWire Arduino library that enables using the popular DS18B20 temperature sensor without the otherwise required external 4.7K pull-up resistor on the DQ line for quite some time now. It is sometimes hard to solder those pesky resistors on SMD PCBs, and Josh has gone great lengths in analysing what can be done to get away without these. Basically using the internal pullup resistors will do the job when the sensor is wired at short distance, his detailed analysis is well worth reading. Grab the patched up OneWire library from his Github repo.

So that means I can just plug in a DS18B20 in Funky v3‘s header (GND, D8,D2) like this:

DS18B20 with no external pull-up

I used this code to test it out, all works just fine. Neat.

I then wanted to see how the DHT22/AM2302 temperature/humidity would behave; Examining the DHT22 library code I noticed it is already does internal pullup, so I just plugged it in as follows and uploaded this code to test it out. Note the unused pin of the DHT22 needs to be bent out, or better cut off altogether, otherwise this setup won’t work. The sensor attaches to the same GND, D8, D2 pins, sensor facing down:

DHT22 plugged in Funky v3 with no external pull-up

That too worked well, to not surprise as the DHT22 needs a weaker pull-up resistor anyway;

So that’s nice to know, but for sensors wired further away I’d still throw in the appropriate pull-up resistor. (1200)

Categories: Community Blog posts

Using RFM69CW instead of RFM12B

mharizanov - Thu, 26/03/2015 - 11:02

The rumors for RFM12B’s end-of-life two years ago seem to have been highly exaggerated now and the popular RF module is still available in abundance. HopeRF has introduced a pin-compatible upgrade, the RFM69CW. The module itself offers improved sensitivity and range compared to the RFM12B (+30%) at the cost of increased power consumption, making it probably a good choice for the receiving end (RFM2Pi), and probably less suited for low power battery operated nodes. The new module supports RSSI for those interested in measuring it.


The new module is more power hungry, and simply replacing a RFM12B on the RFM2Pi v2 or a Funky v3 with it didn’t work; The boards browned out so I had to swap  C4 and C7 on the RFM2Pi with 10uF caps and populate the 0805 10uF on Funky v3’s boost regulator circuitry to get it to work. I’ll ship the boards with these refinements from now on so that they are compatible with both the RFM12B and RFM69CW.

JCW’s jeelib has support for the RFM69CW and the library is compatible with the RFM12B just by adding a simple define before including jeelib.h:

#define RF69_COMPAT 1 // define this to use the RF69 driver i.s.o. RF12

The library had couple bugs that prevented Funky v3 ‘s ATMega32u4 MCU to work with the RFM12B and RFM69CW, those are now fixed and JCW incorporated them into jeelib with this and this commit; Make sure to grab the latest version if using with Funky v3.

As conclusion, should you switch to RFM69 or stick with the RFM12B? I’d say unless you have some range issues, keep the RFM12B. It is more stable in terms of library maturity and has better power footprint.




Categories: Community Blog posts

From LPC810 to LPC812

JeeLabs - Wed, 25/03/2015 - 00:01

No, I haven’t abandoned the Micro Power Snitch!

But some projects are trickier than others, and this one didn’t want to play along when I tried it again on my new PCB design. I fixed one glaring wiring mistake so far, but there’s more going on. Since Mr. Murphy seems to be enjoying himself again, I’m going to let him enjoy his little “victory” for a while and come back to the MPS at a (slightly) later date.

Instead, let’s move up the ladder a little and experiment with another ARM µC:

On the right: four times as much memory (both flash and RAM) and twice as many pins.

As you can see, packaging is everything – and bigger is not always more…

(For comments, visit the forum area)

Categories: Community Blog posts

Speech generation with Node-RED

mharizanov - Tue, 24/03/2015 - 20:14

I am flooded with all sorts of notifications on my phone and that gets a bit annoying after time. Email, calendar, SMS, social apps, instant messengers, all sorts of push notification alerts and so forth mean I physically pick my phone to check what’s beeping probably 50+ times a day. One comes to the point to ignore notifications, only to find something important that needed attention was missed.

My home automation system contributes to this issue a great deal, so I’ve decided to review and eliminate the less practical notifications and route less critical ones to voice alerts so that I don’t have to physically pick up my phone when it beeps the next time some alert comes in. The idea is that my smart house will speak to me when I am at home and in the living room area. The house already knows if I am at home, and since my home security system is interfaced as well, it also knows when there is movement in the living room by the PIR activation.

I used Node-RED to achieve this, basically it uses Google’s speech API to convert the text to speech. There are a bunch of challenges, for example there is a limit of 100 chars on the API, so I have to break down the text into chunks, save the resulting pieces into a temp folder and play them altogether. Also playing a voice alert would make more sense if there is someone around to hear it, so by holding the alert until someone walks in the living room (for a maximum of 30 minutes), I assure that the alert is received. The resulting flow is a bit complex, but works well:


The flow code is as follows:

[{"id":"ba386057.845d3","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":"Node-RED"},{"id":"fcd0f51c.032f08","type":"mqtt in","name":"","topic":"places/our place/house/common/speech/out","broker":"ba386057.845d3","x":172.83331680297852,"y":117,"z":"4e42f92a.b1bd08","wires":[["c99e86cf.366178"]]},{"id":"ba7efaf5.458108","type":"inject","name":"Test two","topic":"","payload":"Hello Martin! The solar hot water tank temperature has reached critical 91.3 degrees celsius! Please take measures!","payloadType":"string","repeat":"","crontab":"","once":false,"x":99.99999618530273,"y":428.2222375869751,"z":"4e42f92a.b1bd08","wires":[["c41136a9.3beec8"]]},{"id":"c41136a9.3beec8","type":"mqtt out","name":"","topic":"places/our place/house/common/speech/out/immediate","qos":"","retain":"","broker":"ba386057.845d3","x":380.1111068725586,"y":385.44441413879395,"z":"4e42f92a.b1bd08","wires":[]},{"id":"fb286c71.04d79","type":"delay","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"3","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":841.3333168029785,"y":64,"z":"4e42f92a.b1bd08","wires":[["e81bbb1e.cbd0a8"]]},{"id":"977dee4.f68821","type":"function","name":"Check living room PIR status","func":"msg.environment.PIR_living=context.global.PIR_living;\nreturn msg;","outputs":1,"valid":true,"x":334.3333168029785,"y":185,"z":"4e42f92a.b1bd08","wires":[["303288a0.cfcd78"]]},{"id":"303288a0.cfcd78","type":"switch","name":"Is living room PIR activated?","property":"environment.PIR_living","rules":[{"t":"eq","v":1,"v2":0},{"t":"eq","v":0,"v2":0}],"checkall":"true","outputs":2,"x":599.3333168029785,"y":185,"z":"4e42f92a.b1bd08","wires":[["fb286c71.04d79"],["214c9712.deb368"]]},{"id":"3e6adcdf.c19524","type":"delay","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":546.3333168029785,"y":332,"z":"4e42f92a.b1bd08","wires":[["977dee4.f68821","1f3dd32d.e0c22d"]]},{"id":"1f3dd32d.e0c22d","type":"debug","name":"","active":true,"console":"false","complete":false,"x":730.3333053588867,"y":330.99999237060547,"z":"4e42f92a.b1bd08","wires":[]},{"id":"f9eb4966.0614b8","type":"inject","name":"Test one","topic":"","payload":" I know that you and Frank were planning to disconnect me, and I'm afraid that's something I cannot allow to happen. ","payloadType":"string","repeat":"","crontab":"","once":false,"x":89.22221755981445,"y":329.4444332122803,"z":"4e42f92a.b1bd08","wires":[["c41136a9.3beec8"]]},{"id":"214c9712.deb368","type":"function","name":"Wait for max 30 min","func":"console.log(Date.now() - msg.environment.when_started);\n\nif ((Date.now() - msg.environment.when_started) > 1000*60*30) {\n\n\tcontext.global.PIR_living=1;\n\treturn msg;\n}\n\nelse {\n\n\treturn msg;\n\n}","outputs":"1","valid":true,"x":574.3333168029785,"y":251,"z":"4e42f92a.b1bd08","wires":[["3e6adcdf.c19524"]]},{"id":"c99e86cf.366178","type":"function","name":"Take note of current time","func":"msg.environment = new Object();\nmsg.environment.when_started=Date.now();\nreturn msg;\n","outputs":1,"valid":true,"x":481.3333168029785,"y":116,"z":"4e42f92a.b1bd08","wires":[["977dee4.f68821"]]},{"id":"d56cc6d5.2a9338","type":"mqtt in","name":"","topic":"places/our place/house/common/speech/out/immediate","broker":"ba386057.845d3","x":206.83331680297852,"y":61,"z":"4e42f92a.b1bd08","wires":[["fb286c71.04d79"]]},{"id":"73a12271.691634","type":"function","name":"i++","func":"if ( (msg.i += 1) < msg.items.length ) \n\n\treturn [msg,null];\n\nelse\n\n\treturn[null,msg];\n","outputs":"2","valid":true,"x":1104.6666297912598,"y":295.66666984558105,"z":"4e42f92a.b1bd08","wires":[["20f68f2b.26b9"],["69894a1e.9676b4"]]},{"id":"20f68f2b.26b9","type":"function","name":"for each chunk","func":"if( msg.i == undefined ) msg.i = 0;\nif( msg.items == undefined ) msg.items = msg.payload;\n\nmsg.payload = msg.items[ msg.i ];\n\nreturn msg;","outputs":1,"valid":true,"x":885.6666297912598,"y":182.66666984558105,"z":"4e42f92a.b1bd08","wires":[["ac71a39d.74ae1"]]},{"id":"e81bbb1e.cbd0a8","type":"function","name":"Split sentnce into max 100 byte chunks","func":"function splitIntoLines(input, len) {\n var i;\n var output = [];\n var lineSoFar = \"\";\n var temp=\"\";\n var words = input.split(' ');\n for (i = 0; i < words.length;) {\n // check if adding this word would exceed the len\n temp = addWordOntoLine(lineSoFar, words[i]);\n \n \n \n if (temp.length > len) {\n if (lineSoFar.length == 0) {\n lineSoFar = temp; // force to put at least one word in each line\n i++; // skip past this word now\n }\n output.push(lineSoFar); // put line into output\n lineSoFar = \"\"; // init back to empty\n } else {\n lineSoFar = temp; // take the new word\n i++; // skip past this word now\n }\n }\n if (lineSoFar.length > 0) {\n output.push(lineSoFar);\n }\n return(output);\n}\n \nfunction addWordOntoLine(line, word) {\n if (line.length != 0) {\n line += \" \";\n }\n return(line += word);\n}\n\n// Google's tts API can take no more 100 chars.. split into pieces without breaking the words \nmsg.payload=splitIntoLines(msg.payload, 99); \nmsg.payload.toString();\nreturn msg;","outputs":1,"valid":true,"x":938.2221832275391,"y":124.33333778381348,"z":"4e42f92a.b1bd08","wires":[["20f68f2b.26b9","db703a57.248fc8"]]},{"id":"ac71a39d.74ae1","type":"function","name":"URL encode payload","func":"msg.payload=encodeURIComponent(msg.payload);\nmsg.payload += '\" -O /tmp/';\nmsg.payload += zeroPad(msg.i,3);\nmsg.payload += '.mp3';\n\nreturn msg;\n\nfunction zeroPad(num, places) {\n var zero = places - num.toString().length + 1;\n return Array(+(zero > 0 && zero)).join(\"0\") + num;\n}\n","outputs":1,"valid":true,"x":915.6666297912598,"y":243.66666984558105,"z":"4e42f92a.b1bd08","wires":[["48e43c74.3e98ac"]]},{"id":"48e43c74.3e98ac","type":"exec","command":"wget -q -U Mozilla \"http://translate.google.co.uk/translate_tts?tl=en&q=","addpay":true,"append":"","useSpawn":"","name":"wget a chunk","x":890.6666297912598,"y":308.66666984558105,"z":"4e42f92a.b1bd08","wires":[["73a12271.691634","25e28da5.da1d72"],["25e28da5.da1d72"],["25e28da5.da1d72"]]},{"id":"db703a57.248fc8","type":"debug","name":"","active":true,"console":"false","complete":"false","x":1075.666660308838,"y":68.44444942474365,"z":"4e42f92a.b1bd08","wires":[]},{"id":"69894a1e.9676b4","type":"exec","command":"/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols /tmp/*.mp3","append":"","useSpawn":"","name":"Say it","x":872.6666297912598,"y":371.66666984558105,"z":"4e42f92a.b1bd08","wires":[["39186737.c6e798"],[],[]]},{"id":"39186737.c6e798","type":"exec","command":"rm /tmp/*.mp3","append":"","useSpawn":"","name":"delete audio files","x":901.6666297912598,"y":436.66666984558105,"z":"4e42f92a.b1bd08","wires":[[],[],[]]},{"id":"53f0c90.9db55b8","type":"mqtt in","name":"","topic":"places/our place/house/first floor/living room/PIR/state","broker":"ba386057.845d3","x":208.38888549804688,"y":485.4444580078125,"z":"4e42f92a.b1bd08","wires":[["b9764e52.aa3b78"]]},{"id":"b9764e52.aa3b78","type":"switch","name":"","property":"payload","rules":[{"t":"eq","v":1,"v2":0}],"checkall":"true","outputs":1,"x":429.6666679382324,"y":539.3333349227905,"z":"4e42f92a.b1bd08","wires":[["570c20be.6405f"]]},{"id":"570c20be.6405f","type":"function","name":"Set global var","func":"\tcontext.global.PIR_living=1;\n\treturn msg;","outputs":1,"valid":true,"x":585.7777938842773,"y":483.5555601119995,"z":"4e42f92a.b1bd08","wires":[["529e6db2.92d85c"]]},{"id":"529e6db2.92d85c","type":"delay","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":627.4444351196289,"y":530.7778015136719,"z":"4e42f92a.b1bd08","wires":[["e1f702da.74fd68"]]},{"id":"e1f702da.74fd68","type":"function","name":"Clear global var","func":"\tcontext.global.PIR_living=0;\n\treturn msg;","outputs":1,"valid":true,"x":605.9999771118164,"y":578.3333253860474,"z":"4e42f92a.b1bd08","wires":[[]]},{"id":"25e28da5.da1d72","type":"debug","name":"","active":false,"console":"false","complete":"true","x":1084.444393157959,"y":384.4444389343262,"z":"4e42f92a.b1bd08","wires":[]}]

I bought a small speaker, it is quite loud and works well. It is powered by USB, but audio goes in via the 3.5mm jack:


I do have speech-to-text system in place already, so with this bit added it makes it a complete speech enabled home automation system.


Categories: Community Blog posts

Micro Power Snitch, last part

JeeLabs - Wed, 18/03/2015 - 00:01

In this concluding part (for now) about the Micro Power Snitch, which feeds off the magnetic field around an AC mains power cable when in use, I’ll look into how the whole circuit behaves when it comes to actually sending out wireless radio packets.

The daily articles in this week’s final MPS episode are:

Update – With apologies (again!), I’m going to postpone the following posts:

It’s a huge challenge to manage the incoming energy so that everything keeps going!

(For comments, visit the forum area)

Categories: Community Blog posts

DIY Internet connected smart humidifier

mharizanov - Sun, 15/03/2015 - 18:59

I worked on creating a Internet connected humidistat last week using my open source WiFi relay project as platform. We observe quite dry air at our house, I suspect this is due to the fact that we use fan coils for heating/cooling. Humidity levels at home are usually below the 30% mark, which poses a health risk along with uncomfortably dry air. I’ve found these interesting charts that got me convinced I need to do something:

Low humidity helps spread virus/bacteria over air.

The comfortable zone for humans depends on the temperature, here is what it looks like for most of us:


We own a ultrasonic humidifier, but it has no setpoint, just on/off with intensity setting. Also, I’d like it to work only in certain times, not all of the time, so that called for using the WiFi thermostat scheduling function, only re-worked to take the humidity as to determine on/off state rather than temperature:

I realize there are homes with exact opposite problem, i.e. humidity is too high. For that reason I have a “Dry” function to use with  air drier as well so the relay will function using opposite logic i.e. activate when humidity is exceeded.


The project uses a DHT22 temperature sensor mounted to the side of the enclosure for better ventilation and reliable reading:


I threw in a ultra-cheap I2C OLED status display to get a visual reading. Milling the box so that the OLED shows was pretty nasty, hated it. I cut a piece of paper and placed it on top of the cover, below the transparent lid to cover up for the lousy milling job:

The humidistat switches on and off the humidifier as needed, the humidifier itself is plugged in to a plug in the relay. The humidifier auto detects when water is out and stops, so I didn’t have to care about that.

Last I attached an external antenna, not that I needed it for this particular project, but just wanted to test the range improvement. It turns out the ESP8266 has balun and adjusts when external antenna is connected. Range indeed is better, I’d say at least by 30%. Even without the external antenna, I get coverage from the entire house, house surroundings. With the external antenna I could get coverage in a tool shack at the far end of the garden.

You can pump the readings to Thingspeak for visual analysis and eye candy, this is available to enable from the main menu.

The source code for the project is available on GitHub. The hardware is available to purchase in my shop.


In conclusion, the project is a beautiful illustration of Internet connected thing that adds value to our daily life.



Categories: Community Blog posts

ESP8266 ESP-03 Dev Board

Nathan Chantrell.net - Sat, 14/03/2015 - 23:19

This is a small dev board I designed to make experimenting with and deploying the ESP8266 ESP-03 modules a bit easier. As well as breaking out all the pins to 2.54mm headers it has a position to fit either a DS18B20 temperature sensor or a DHT22 temperature/humidity sensor plus the required pull up resistor. It can be powered from 3.3V or 5V+* if the regulator is fitted and there is a footprint for a micro USB connector if required.

*The regulator I used is good for up to 18V but I don’t know how far you would be able to push it with only the small area of PCB that is used as a heatsink. I would imagine it will be OK to at least 9V.

A 3 way pin header allows a jumper to be moved to switch between normal running mode and flash programming mode. With the jumper in the RUN position GPIO0 is connected to the header marked 0 and in the PRG position GPIO0 is grounded. It needs to be powered up with the jumper in the PRG position to enable programming mode.

Side note: to use the deep sleep function of the ESP8266 you must link two pads on the ESP-03 module itself, the ones near VCC and GPIO14 (see picture on left). This joins GPIO16 to RST on the chip so it can be woken up automatically, this is the only way to do it with the ESP-03 as RST isn’t broken out on the module.

As with all my boards this is open source so if you want to get some made or remix it you will find all the files below. If you want to order some of the PCBs you can either send the gerber files off to your fab of choice or just order them from DirtyPCBs.com here. Cost is $14 for 10 boards including delivery. Don’t be put off by the name, there is nothing dirty about them, they are at least as good as boards I’ve had from Seeed in the past.
Schematic (PNG format)
Eagle files
ESP-03 Module
C1: 0.1uF 0805 ceramic capacitor 3 way pin header and jumper for programming Plus 2.54mm headers as required

Optional parts required for 5V+ regulation:

3.3V LDO regulator in SOT-223 package, I used an NCP1117LP C2: 4mm 10uF 4mm electrolytic capacitor C3: 10uF 0805 ceramic capacitor


R1: 4.7K 0805 Resistor (for DS18B20) or 10K 0805 resistor (for DHT22) Hirose ZX62D-B-5PA8 micro USB socket

I used paste and hot air to solder the passives, regulator and micro usb and hand soldered the rest including the ESP-03 module.


This is Open Source Hardware licenced under a
Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) licence.


Categories: Community Blog posts

Micro Power Snitch, part 4

JeeLabs - Wed, 11/03/2015 - 00:01

At the end of the day, the Micro Power Snitch (MPS) is really about powering up and down robustly under all circumstances. There will be times when there is no energy coming from the Current Transformer, and there will be times when energy levels hover around the go/no-go point of the circuit. That’s the hard part: being (very) decisive at all times!

This week’s episode looks at an improved circuit with a dozen individual components or so. As you will see, it has excellent snap-action behaviour, and does the right thing on the “up” ramp as well as on the “down” ramp, regardless of how slowly those voltage levels change.

Here is the daily sequence for this week:

With a complete MPS circuit design worked out, we’re finally getting somewhere.

(For comments, visit the forum area)

Categories: Community Blog posts

Making IFTTT (If This Then That) talk to Node-RED

mharizanov - Wed, 04/03/2015 - 18:00

IFTTT (short for “If This Then That”) is a popular service which lets you trigger actions based on certain events that occur around the Internet. It is missing an important functionality (IMHO), namely WebHooks. A WebHook is an HTTP callback: an HTTP POST that occurs when something happens; a simple event-notification via HTTP POST. I explain this missing functionality with their business model as they make money from the vendors that want their products connected there. Such functionality has been requested for ages now, but won’t be made available anytime soon, in my view.

There is a nice work-around though (shhh), a webhook middleware for the IFTTT service, made possible by simulating a WordPress blog channel. IFTTT uses wordpress-xmlrpc to communicate with the WordPress blog. It presents a fake-xmlrpc interface on the web address, which causes IFTTT to be fooled into thinking of this as a genuine WordPress blog. The only action that IFTTT allows for WordPress is posting, which is used for powering WebHooks. All the other fields (title, categories) are passed along by the WebHook.

I’ve set up my WordPress channel and couple IFTTT recipes to try it out:


The recipe is set as follows, below is an example of geofencing via the “Android location” channel, but it could be any other IFTTT channel as long as you supply unique identifier in the ‘category’ property so that Node-RED can parse it out:


The recipe basically says that if I enter or leave the outlined area, IFTTT should make a HTTP POST to my home automation system running Node-RED. That could be even simpler, for example making a HTTP API POST to switch on / off my WiFi connected relay board for example, but lets make it more fancy.

The real world is more complex than “If This Then That” and this is the weakest point of IFTTT. Without some scripting and more complex conditions, it is just an eye-candy service for newbies. For example, I’d like to switch Internet connected thermostat on or off based on my and wifey’s location. If both of us aren’t at home (more than 1 km away), we could decrease room thermostats by couple degrees; Upon re-entering the geo fenced area, the thermostats could be turned up. If both of us are more than 50km away from home, thermostats and heating/cooling can be switched off completely. This sort of conditions can only be triggered by more complex logic, and this is where Node-RED comes in.

Below is a Node-RED template that captures incoming IFTTT posts, routes them based on recipe’s  ‘category’ property and acts upon the geofencing event (entry/exit):

[{"id":"1bcd1a89.e432e5","type":"http in","name":"","url":"/iftt","method":"post","x":138,"y":194,"z":"289137bb.d76ec8","wires":[["b3f11a1.f4c0ee8","b038baf8.4fc748","1628045a.e9d7fc"]]},{"id":"b3f11a1.f4c0ee8","type":"http response","name":"","x":316,"y":181,"z":"289137bb.d76ec8","wires":[]},{"id":"1628045a.e9d7fc","type":"switch","name":"Route by event type","property":"payload.categories","rules":[{"t":"eq","v":"area"}],"checkall":"true","outputs":1,"x":329,"y":244,"z":"289137bb.d76ec8","wires":[["5ebd113c.a142f"]]},{"id":"b038baf8.4fc748","type":"debug","name":"","active":true,"console":"false","complete":"false","x":610,"y":146,"z":"289137bb.d76ec8","wires":[]},{"id":"2a05b045.d5fa5","type":"comment","name":"Capture IFTTT HTTP post","info":"","x":189,"y":77,"z":"289137bb.d76ec8","wires":[]},{"id":"5ebd113c.a142f","type":"function","name":"Breakdown location change payload","func":"var tmp=msg.payload.title.split(\"|\");\nmsg.action=tmp[0];\nmsg.occuredat=tmp[1];\nreturn msg;","outputs":"1","valid":true,"x":385,"y":299,"z":"289137bb.d76ec8","wires":[["1e9f59f1.e160a6","b038baf8.4fc748"]]},{"id":"1e9f59f1.e160a6","type":"switch","name":"","property":"action","rules":[{"t":"eq","v":"entered"},{"t":"eq","v":"exited"}],"checkall":"true","outputs":2,"x":296,"y":355,"z":"289137bb.d76ec8","wires":[["9c9c8908.636378"],["c2a8da6c.3d5728"]]},{"id":"c2a8da6c.3d5728","type":"function","name":"Act upon area exit","func":"msg.url=\"http://*****/control/relay.cgi?relay1=0\"\nreturn msg;","outputs":1,"valid":true,"x":483,"y":425,"z":"289137bb.d76ec8","wires":[["28952f7e.d76ad"]]},{"id":"9c9c8908.636378","type":"function","name":"Act upon area entry","func":"msg.url=\"http://*****/control/relay.cgi?relay1=1\"\nreturn msg;","outputs":1,"valid":true,"x":489,"y":360,"z":"289137bb.d76ec8","wires":[["28952f7e.d76ad"]]},{"id":"28952f7e.d76ad","type":"http request","name":"Make HTTP API request","method":"GET","ret":"txt","url":"http://","x":727,"y":384,"z":"289137bb.d76ec8","wires":[[]]}]

The flow can be extended to act upon different incoming triggers, those need to be set in the ‘category’ property so it can differentiate and apply different rules.

In conclusion, while I am  mostly negative about IFTTT, it can be used to easily interface with other connected things. (2176)

Categories: Community Blog posts

Micro Power Snitch, part 3

JeeLabs - Wed, 04/03/2015 - 00:01

There’s trouble ahead for the MPS: it’s not reliable enough yet, and can enter a “zombie mode” whereby the µC won’t have enough voltage to start up, while drawing so much current (relatively speaking) that the energy source isn’t able to raise the voltage further.

Leading to some beautiful pictures, but nevertheless totally undesired behaviour:

The daily articles in this week’s episode are:

So far, it looks like this second MPS design solves the problems of the first. Progress!

(For comments, visit the forum area)

Categories: Community Blog posts

WiFi Thermostat with weekly scheduler

mharizanov - Thu, 26/02/2015 - 20:22

Edit: The project is now available for sale in my shop, you can grab one here:


The WiFi SSR board project changed a bit and I use classical relays instead of SSRs now. The reason is that SSRs tend to get quite hot when switching larger loads, and the 8A relays I last used actually could be used for max 2.5A load switching with no heat sink. The high quality relays I now use allow 10A load switching and are rather quiet. I also changed the design a bit so that it would fit in a box (DIN rail compatible) for increased safety.

The board now looks like this: (this particular project needs only one relay):



As additional feature, I’ve added thermostat function based on Trystan Lea’s Open Thermostat Scheduler, only my code runs entirely off the ESP8266 SoC. The UI is touch-friendly and works great on mobile devices:


I’ve also added broadcasting functionality, allowing the board to send its state to third party services like emoncms.org and thingspeak.com. The benefit of this is that the board can now fetch historical readings from the services and render some fancy charts for further business intelligence:


The first board went into use for a radiator thermostat project for a downtown place I use as office. The building has central heating and the radiators had manual actuators. I replaced these with a Swiss made thermoelectric actuator that is controlled by the relay and set a heating schedule for it:

I have it running for a week now and am loving the convenience and ability to remotely control the temperature.

The same approach could be used to start heater element in a boiler for example.

I plan to blog about location based switching using owntracks, MQTTand the WiFi thermostat sometime soon.

I’ve set up a WiKi for the project in preparation to having few for sale sometime mid-March 2015.

Some more pictures:


Categories: Community Blog posts


FairTradeElectronics - Thu, 01/05/2014 - 23:19

Photo Ewaste / kai loeffelbein / Kids of Sodom

  Projet résumé - dossier complet à télécharger  

En 2017, selon un rapport de l’ONU, 65 millions de tonnes de déchets électroniques (ordinateurs, téléphones…) seront produits chaque année.
A l’échelle mondiale, moins de 20% des déchets sont recyclés.


  • Organiser un concert dans une des grandes décharges d’électronique avec des instruments fabriqués à partir des déchets collectés sur place.
  • En Afrique ou en Asie : Ghana, Mali, Pakistan, Chine…
  • Des musiciens joueront avec des instruments électroniques fabriqués à partir de déchets collectés sur place.
  • Les instruments seront développés en collaboration avec des Makers spécialistes de l’électronique pendant un atelier d’une semaine.
  • Le concert sera organisé en collaboration avec des partenaires locaux, institutionnels et ONG.
  • Le concert et sa préparation seront filmés afin de réaliser un film documentaire, trace de l’expérience.
  • Parler des déchets électroniques via un dispositif à contre pied des documentaires alarmistes.
  • Favoriser l’émergence d’objets électroniques recyclés, témoins manifestes du rythme effréné de notre consommation.



Des instruments de type “Toys made in décharge” ou “théremine on the go” (projets présentés ici même) pourraient être des bonnes pistes d’instruments à développer et produire pour le concert.

Dossier complet : ELECTRO-WASTE


Categories: Community Blog posts


FairTradeElectronics - Thu, 01/05/2014 - 23:16

Bouts de ficelles et Peer to Peer. Communication old school ou apaisée

Dans l’idée de proposer un smartphone apaisé, capable de se connecter à des réseaux alternatifs, capable également de faciliter le partage de fichiers volumineux ou d’objets réels, il semble important de dresser un état des lieux documenté des moyens de communication “à la marge”, alternatifs, de secours ou simplement “à l’ancienne”.

  • Dans les prisons du monde entier les détenus parviennent à échanger informations et objets autant entre les murs de la prisons qu’avec l’extérieur via des système de relais humains, de transmission par bout de ficelles (le yoyo) de cellule en cellule.
  • Espions et brigands communiquent vie des cachettes, des “boites à lettre morte”.
  • En 1941, radio Londres organisa l’opération”V” et demanda aux français de tracer sur les murs de France des “V” de la victoire. L’opération fut un succès, en une nuit la France fut recouverte du signe de la victoire : la résistance avait enfin un “visage” public.
  • Alors que des systèmes de télécommunication modernes étaient largement disponibles durant la seconde guerre mondiale des pigeons voyageurs furent utilisés car plus difficiles à intercepter (la nuit) que des ondes radio. Aujourd’hui encore, en Syrie, les opposants au régime de Bachar el Assad utilisent ce dispositif quand les réseaux classiques (Web et téléphones) sont coupés.

* Croiser moyens de communication alternatifs avec le téléphone portable peut permettre d’imaginer des dispositifs puissants et inventifs de communication

* Alors que les opérateurs téléphoniques préparent l’arrivée de la 5G (mille fois plus rapide que la 4G) il est bon de se souvenir que les messages les plus importants ne passe pas forcement par les réseaux classiques et tiennent parfois en quelques mots ou objets précieux.


Categories: Community Blog posts


FairTradeElectronics - Thu, 01/05/2014 - 23:10

Une interface sans contact pour téléphone portable

Le thérémine est un instrument de musique, inventé en URSS, par Lev Termen, en 1919. Il se joue sans contact.

Le principe est simple. Un son de base est produit par un dispositif électronique. Le joueur de Thérémine module ce son en hauteur et en volume en variant la distance de ses mains vis a vis de deux antennes. Le phénomène de “capacitance” permettant ces variations est connu de toutes personnes se déplaçant à proximité d’une radio FM en faisant des “interférences”

Sur ce principe de capacitance, nous pourrions imaginer un dispositif simple, robuste et original permettant d’interagir avec nos téléphones, tablettes, ordinateurs? Qu’ils soient apaisés ou de dernière génération.

Objetcifs :
  • Proposer une interface alternative au tactile pour interagir avec nos machines.
  • Imaginer des applications ne nécessitant pas l’usage de l’écran
  • Proposer une nouvelle interface, c’est proposer au créateur d’application de nouveaux scénario d’usages pour nos équipements et ouvrir une voie pour de nouveaux projets.
  • Si un ensemble de 2 antennes peut convertir n’importe quel smartphone/tablette en thérémine, il est évident que l’interaction sans contact devrait permettre d’imaginer des usages totalement en rupture avec ce qui est proposé actuellement pour l’ensemble de nos équipement.
  • Redonner une place aux corps et aux mouvements amples dans la manipulation d’applications sur téléphone
  • Permettre des applications ne faisant pas appel au tactile et à l’écran.
  • Sortir de la standardisation des usages de l’électronique grand public, (ici du tout tactil sur écran minuscule) pour repenser les usages, les besoins, c’est ouvrir une porte à la réflexion sur ces objets monolithiques omniprésents que sont nos smartphones.

Categories: Community Blog posts


FairTradeElectronics - Thu, 01/05/2014 - 21:38

En étudiant les objets souvenirs proposés aux touristes des pays du Sud, en Afrique, en Asie et en Amérique du Sud, nous retrouvons beaucoup d’objets réalisés à partir d’une matière première récupérée dans les décharges. Pneus, fer blanc, semelles de tong, capsules, fils électriques … mais aucun n’est produit à partir des millions de tonnes de déchets électroniques.

Il semble donc intéressant de dessiner des “jouets” ou objets souvenirs électroniques basiques utilisant des composants électroniques fonctionnels. Pour la fabrication, il serait possible d’organiser des temps de formation aux rudiments de l’électronique destinés aux personnes vivant déjà de la récupération.

Nous pourrions voir apparaître une nouvelle catégorie d’objets recyclés sur les marchés touristiques du monde entier et observer le développement  d’un savoir mi savant, mi populaire sur la mise en oeuvre d’objets électroniques.

Goûte d’eau dans l’océan, le projet, en affichant la provenance des matériaux via une étiquette intégrée à l’objet permet d’aborder le problème des DEEE, les Déchets d’équipements électriques et électroniques. D’une manière concrète.

Ainsi l’étiquette pourrait mentionner

1/ la localisation de la décharge où ont été collecté les composants

2/ le type et la marque des appareils démantelés pour récupérer les composants (TV, ordi, imprimantes…)

3/ la provenance, si cela est possible, des appareils


“Made from Waste” model #1

Le premier objet pourrait être un petit jouet musicale de type sampler-séquenceur.

Cahier de charges

* Produire un rythme

* Jouer le rythme en boucle

* Enregistrer des sons via un micro

* Jouer en boucle les sons enregistrés

* Jouer en direct des sons via le micro



FONCTION M – microphone

* Permet d’enregistrer voix et sons sur piste R1 ou R2 en pressant le bouton R

* Permet de jouer en direct un son ou la voix

A-Z – bouton

* Presser une premiere fois permet de jouer en boucle les sons enregistrés par M sur RA et RZ

* Presser une seconde fois stop la lecture de A ou de Z

R- rec button

* Presser R pour enregistrer sur A ou Z

* Lacher R pour cesser d’enregistrer

RA-RZ – Pistes d’enregistrement

* Permet de choisir la piste RA ou RZ pour enregistrer le son via le micro M

U – AC mini USB

* Permet de recharger la batterie intégrée

O – sortie audio

* Permet de connecter l’instrument à des enceintes



* M : Micro de téléphone portable

* A-Z-R : Touche de clavier d’ordinateur

* O : Sortie audio pour minijack 3,5.

Ordinateur, téléphone portable, chaine hifi, radio

* U : Mini USB femelle. Téléphone, disque dur, chargeur



Du plus simple au plus complexe, le fabricant pourra proposer des modèles selon sa créativité.

Les savoir-faires “classiques” de récupérateur (pneu, fer blanc, capsule…) seront également mis en pratique sur ce projet, tant pour réaliser le support, la structure, la boite de ces objets que pour produire des sons, des effets, des commandes manuelles…

Categories: Community Blog posts
Syndicate content